필터 지우기
필터 지우기

how do i fprintf 2 variables like this

조회 수: 1 (최근 30일)
Austin
Austin 2013년 10월 1일
댓글: Austin 2013년 10월 2일
kindly advise,thanks alot!

채택된 답변

Image Analyst
Image Analyst 2013년 10월 1일
for row = 1 : 6
fprintf('The sum of row %d = %f\n', row, sum(yourMatrix(row, :)));
end
  댓글 수: 1
Austin
Austin 2013년 10월 2일
Thanks Alot your solutions works!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2013년 10월 1일
편집: dpb 2013년 10월 2일
One way amongst many...
>> sfx={'st';'nd';'rd';'th'};
>> isf=[1:3 repmat(4,1,3)];
>> for ix=1:6
fprintf('The sum of %d%s row is %.3f\n',i, sfx{isf(ix)}, sum(x(ix,:)))
end
The sum of 1st row is 0.564
The sum of 2nd row is 1.843
The sum of 3rd row is 0.702
The sum of 4th row is 1.888
The sum of 5th row is 1.551
The sum of 6th row is 0.627
>>
  댓글 수: 1
Austin
Austin 2013년 10월 2일
Thanks Alot your solutions works too!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by