using a cell array
이전 댓글 표시
Hi,
My problem - I've created a script that works in one computer. I've copied it to three other computers. I also copied the excel and bmp files used in the script, but not shown below. On the other three computers I get the same error message. the right hand side of this assignment has too few values to satisfy the left hand side and it points to the script below.
the relevant part of the script follows
[number1, trainingwordd] = xlsread('trainingword.xls', 'A1:B1')
trainingword = cell(1,1)
trainingword = trainingwordd{1,1}
number1 = double(number1);
otherstuff
trainlearnedorder{1:25,1} = trainingword;
the error message occurs here and points to the above line.
I've checked and trainingword = a sequence of letters as it is supposed to.
Any suggestions would be appreciated. I'm using Matlab 7.11.0 (2010b) on all four computers. I copied the script from the computer I developed it on to the other computers.
Thanks for your help.
Jim
댓글 수: 1
Matt J
2012년 11월 26일
It's not clear why you have this line, if you intend trainingword to be a character string
trainingword = cell(1,1)
In any case, you may as well remove it. It's not accomplishing anything.
답변 (1개)
I think you intend this
[trainlearnedorder{1:25,1}] = deal(trainingword);
or this
trainlearnedorder(1:25,1)={trainingword};
How your original code worked on even one of the computers is a mystery to me.
댓글 수: 3
Jim
2012년 11월 26일
Then there's something you're not telling us about what your data looks like. It works fine for me as the following example shows, assuming that trainingword is indeed a string of characters as you say. I suspect, though, that trainlearnedorder already exists as a non-cell array in your workspace. The solution would be to clear it, if you now want it to be a cell.
>> trainingword='abc'; trainlearnedorder(1:25,1)={trainingword}
trainlearnedorder =
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
'abc'
Jim
2012년 11월 29일
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!