How to use fprintf in the following situation?

1 次查看(过去 30 天)
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 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by