In an assignment A(I) = B, the number of elements in B and I must be the same.

1 回表示 (過去 30 日間)
reyadh Albarakat
reyadh Albarakat 2015 年 4 月 13 日
コメント済み: reyadh Albarakat 2015 年 4 月 15 日
Hi Guys, first of all I am beginner in Matlab. I want to get Average Values of NDVI for each month during a year. I used this
i=1:12;
jan(i)=ndvi_avhrr_monthly_avg{i};
and then I got this Error (((In an assignment A(I) = B, the number of elements in B and I must be the same.))).
Thanks
Reyadh
  2 件のコメント
Jan
Jan 2015 年 4 月 13 日
Please format your code properly. I've fixed this for you today.
pfb
pfb 2015 年 4 月 13 日
編集済み: pfb 2015 年 4 月 13 日
exactly the same question was asked a few minutes before :)
And possibly a million times before.

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

採用された回答

Jan
Jan 2015 年 4 月 13 日
jan(i) is a scalar and obviously the contents of ndvi_avhrr_monthly_avg{i} is not a scalar. Therefore the right hand side cannot be assigned to the left hand side.
  3 件のコメント
Image Analyst
Image Analyst 2015 年 4 月 13 日
ndvi_avhrr_monthly_avg{i} needs to be a single number to assign it to an element of an array like that. What does this say
cellContents = ndvi_avhrr_monthly_avg{i}
whos cellContents
It will be more than one element. For exmaple cellContents might be a 42 by 300 matrix. So which element do you want to take from cellContents and stuff into jan(i)? Or you can make a structure and just attach the whole array:
simon.theArray = cellContents; % Transfer ALL of the elements.
reyadh Albarakat
reyadh Albarakat 2015 年 4 月 15 日
Thank you so much Jan

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

その他の回答 (0 件)

カテゴリ

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