Undefined function 'times' for input arguments of type 'cell'

99 visualizaciones (últimos 30 días)
enrica
enrica el 9 de Oct. de 2014
Comentada: Ayswaria Vijayamohan el 20 de Oct. de 2020
I'm performing the lme model with longitudinal data analyzed using free surfer, I have created this matrix:
X = [ones(length(M),1) M M(:,1).*M(:,2)];
but I have the following error
Undefined function 'times' for input arguments of type 'cell'.
What is it wrong? enrica
  1 comentario
Oleg Komarov
Oleg Komarov el 9 de Oct. de 2014
M is a cell array and multiplication is not defined for cell arrays.

Iniciar sesión para comentar.

Respuesta aceptada

Iain
Iain el 9 de Oct. de 2014
When you want to access the contents of "M", you need to access it like this:
M{:,1}
  4 comentarios
enrica
enrica el 9 de Oct. de 2014
I would like to create a matrix X where the first column is the column of 1s (the intercept), the 2nd column the time covariate (took from the column 1 of matrix M), 3rd column with the group (took from the column 2 of matrix M) and the interaction term of two previous variables (time*group) M{:,1}.*M{:,2} Sorry, but this is my first time with matlab.
Iain
Iain el 9 de Oct. de 2014
There's no need for you to apologise. :)
Try the code, look at the answer, decide for yourself if it's working. If it's working, great. If it's not, and you can't figure out how to put it right, ask another question.

Iniciar sesión para comentar.

Más respuestas (1)

g.shaanti
g.shaanti el 15 de Dic. de 2016
Hello, I realize this is an older post, but I would like to put another possibility out there for what can be wrong (and a solution):
This is for if you've ensured that the function you're trying to call both exists and is definitely on your path, but MatLab is still throwing this error (as was the case for me).
The folder containing the function I was trying to run was labelled with slightly unusual characters (so that it would appear at the top of the directory where I needed it).
Folder title: "--> title of folder" (the quotes are not part of the folder title)
I finally got the function to run when I moved it into a folder outside of "--> title...", and it ran without a problem. I have a feeling the "-->" characters in the folder title caused the error, which might be related to how MatLab accesses files when looking for the function you called.
Hopefully this is clear enough to understand and helps as an alternative if someone else runs into this.
  2 comentarios
NOR AZIEYANI
NOR AZIEYANI el 16 de Dic. de 2018
Hi. I'm trying to understand the above comment. But I still get the same error. Can you checkout this code. Undefined function 'exist' for input arguments of type 'cell'.
wordsstring = regexp(words,'\w+', 'match');
wavdirectory = 'C:\R2013a\bin\Recordings';
[~, number_of_words] = size(wordsstring); %stores number of words in user
% input string
for m = 1:number_of_words
filename = [wavdirectory wordsstring{m} '.wav'];
if(exist(filename, 'file' ~= 0));
filename = [wavdirectory wordsstring{m} '.wav'];
[y, fs] = audioread(filename); %this tests for Case 1 (base word)
sound(y, fs);
Ayswaria Vijayamohan
Ayswaria Vijayamohan el 20 de Oct. de 2020
Thank you. this was helpful. I faced the same issue. Mo folder name had a '_2' in the name.When the folder name was changed, it worked.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by