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

조회 수: 147(최근 30일)
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
Oleg Komarov
Oleg Komarov 2014년 10월 9일
M is a cell array and multiplication is not defined for cell arrays.

댓글을 달려면 로그인하십시오.

채택된 답변

Iain
Iain 2014년 10월 9일
When you want to access the contents of "M", you need to access it like this:
M{:,1}
  댓글 수: 4
Iain
Iain 2014년 10월 9일
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.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

g.shaanti
g.shaanti 2016년 12월 15일
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
Ayswaria Vijayamohan
Ayswaria Vijayamohan 2020년 10월 20일
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.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by