フィルターのクリア

Subscript indices must either be real positive integers or logicals- Size() Function in Matlab

1 回表示 (過去 30 日間)
I am having a strange problem. I have a cell array that is 4x4. In each cell is a double array that is about 103x33, but can vary. I am trying to make a loop to create a variable y.
y=cell(m,n)
for i=1:m
for j=1:n
y{i,j}=size(cellarray{i,j},1)
end
end
However this gives the error: Subscript indices must either be real positive integers or logicals
What is weird is that I cant even do one sample size in matlab.
If I do (not even in a loop):
y=size(cellarray{1,1},1)
This returns the same error. It is weird because if I export the variable cellarray to matlab, I can then use the size command to get its size, but for some reason it will not run in the program.
Any help would be greatly appreciated!
  1 件のコメント
Andrew Newell
Andrew Newell 2012 年 1 月 4 日
Are you sure |m| and |n| are integers? What do you get if you enter the following commands?
cellarray = cell(2,2);
y=size(cellarray{2,2},1)

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

採用された回答

Jan
Jan 2012 年 1 月 4 日
I guess you have overwritten a function by a local variable:
which size
which cell

その他の回答 (1 件)

ASMS Mat Su
ASMS Mat Su 2012 年 2 月 21 日
Jan Simon;
What do you mean by
which size
which cell
I don't understand. I'm having a similar problem too... how can we fix that in the codes?
thanks
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 2 月 21 日
At the MATLAB command line, type in the command
which size
and the command
which cell
This will show you whether "size" and "cell" are local variables or are routines, and if they are routines it will show you where they are located. If either one of them shows up as a variable, then you have accidentally used a variable name the same name as a MATLAB function: when you do that, you lose the ability to refer to the function (without going to a lot of bother.)

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by