How to use fprintf in the following situation?
2 views (last 30 days)
Show older comments
Taner Cokyasar
on 9 Jul 2016
Answered: Azzi Abdelmalek
on 9 Jul 2016
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.
0 Comments
Accepted Answer
Azzi Abdelmalek
on 9 Jul 2016
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 Comments
More Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!