Problem 32. Most nonzero elements in row
이전 댓글 표시
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
카테고리
도움말 센터 및 File Exchange에서 Numeric Solvers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!