필터 지우기
필터 지우기

How to use fprintf in the following situation?

조회 수: 2 (최근 30일)
Taner Cokyasar
Taner Cokyasar 2016년 7월 9일
답변: Azzi Abdelmalek 2016년 7월 9일
Hello,
I have following vectors tmvalues and Zimfi. I am finding Yvalues vector by using those two and finding the following answer.
tmvalues - Zimfi = Yvalues
12 0 12
11 0 11
10 6 4
12 0 12
11 3 8
10 0 10
12 0 12
11 5 6
10 0 10
Then, to print Yvalues with its title, I am using the following code (i=m=3) and having the following output:
[Y1,Y2] = meshgrid(1:i,1:m);
Ytitle = [Y1(:),Y2(:),Yvalues(:)];
fprintf(' Y%d%d %d\n',Ytitle.')
Y11 12
Y12 11
Y13 4
Y21 12
Y22 8
Y23 10
Y31 12
Y32 6
Y33 10
However, I don't want to print the rows of Yvalues answer, where Zimfi element is 0. So, I actually want to have this result.
Y13 4
Y22 8
Y32 6
How can I eliminate the rows of Yvalues which of its Zimfi element is 0? Sorry for writing so long. I wanted to make it as clear as possible. I really appreciate for your answers.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 9일
M=[ 12 0 12
11 0 11
10 6 4
12 0 12
11 3 8
10 0 10
12 0 12
11 5 6
10 0 10]
[Y1,Y2] = meshgrid(1:3,1:3);
Ytitle = [Y1(:),Y2(:),M(:,3)]
Ytitle=Ytitle(M(:,2)~=0,:)
fprintf(' Y%d%d %d\n',Ytitle.')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by