the next code without for loop display accurately results but when use the loop show error "Assignment has more non-singleton rhs dimensions than non-singleton subscripts", why ? and What can I do to solve this problem?
1 回表示 (過去 30 日間)
古いコメントを表示
mohammed elmenshawy
2016 年 8 月 16 日
コメント済み: mohammed elmenshawy
2016 年 8 月 24 日
for i=1:30
b(i,:,:)=nonzeros(A(i,:,:));
bb(i,:,:)=unique(b(i,:,:));
bbb(i)=sum(bb(i,:,:))/length(bb(i,:,:));
end
1 件のコメント
John BG
2016 年 8 月 17 日
not enough data.
Please supply the chunk of code that we can reproduce, and get the same error.
Simplify anything you don't want to explain, but without code that can be readily reproduced, you force readers to a lot of guesswork without clear aim.
Awaiting answer
採用された回答
Image Analyst
2016 年 8 月 17 日
Also, look up what length() and squeeze() do (you might be surprised). Next, assign some of those things to intermediate variables before sending them into unique(), length() and other functions and see what their sizes are by using THE DEBUGGER
For example:
temp1 = bb(i,:,:);
whos temp1
temp2 = length(temp1);
whos temp2
temp3 = sum(temp1);
whos temp3
bbb(i)= temp3 / temp2;
It's just basic debugging.
3 件のコメント
Image Analyst
2016 年 8 月 24 日
Get rid of the "whos" commands and put semicolons at the end of every line to suppress echoing results to the command window.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!