Problem 32. Most nonzero elements in row
1 回表示 (過去 30 日間)
古いコメントを表示
function r = fullest_row(a)
x=sum(a==0);
y=max(x);
row=0;
for i=1:length(x)
if x(i)==y
row=i;
end
r=row;
end
whats wrong with the code???
2 件のコメント
Azzi Abdelmalek
2013 年 7 月 15 日
編集済み: Azzi Abdelmalek
2013 年 7 月 15 日
Give a short example: a= ... and what should be the result?
Jan
2013 年 7 月 15 日
@ricardo: Please do not let us solve your Cody problems. This is not the intention of this game and of this forum.
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2013 年 7 月 15 日
I don't know what should be the result r, but I can see that the value of r is erased each loop
r=rows
maybe you can initialize r
r=[]
then write
r(end+1)=rows
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!