using a cell array

2 ビュー (過去 30 日間)
Jim
Jim 2012 年 11 月 26 日
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
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 件)

Matt J
Matt J 2012 年 11 月 26 日
編集済み: Matt J 2012 年 11 月 26 日
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 件のコメント
Matt J
Matt J 2012 年 11 月 26 日
編集済み: Matt J 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
Jim 2012 年 11 月 29 日
You were correct - there was a different problem, a different excel file did not have the string it should have hed.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by