using a cell array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Matt J
el 26 de Nov. de 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.
Respuestas (1)
Matt J
el 26 de Nov. de 2012
Editada: Matt J
el 26 de Nov. de 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 comentarios
Matt J
el 26 de Nov. de 2012
Editada: Matt J
el 26 de Nov. de 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'
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!