using a cell array

2 views (last 30 days)
Jim
Jim on 26 Nov 2012
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 Comment
Matt J
Matt J on 26 Nov 2012
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.

Sign in to comment.

Answers (1)

Matt J
Matt J on 26 Nov 2012
Edited: Matt J on 26 Nov 2012
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 Comments
Matt J
Matt J on 26 Nov 2012
Edited: Matt J on 26 Nov 2012
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
Jim on 29 Nov 2012
You were correct - there was a different problem, a different excel file did not have the string it should have hed.

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!