how can I let the string variable change in a loop

2 次查看(过去 30 天)
Dear fellows,
I am trying to plot the scatter for a set of vectors. My secource file pf.mat is a 65*154 matrix. I want to plot two columns each time so I am writing a loop (i=1:77)from 1 to 77. In each loop, after plot the vectors, I would to save the image as the number of the i. My questions is how do I name the image then it can change as th loop goes on? My current code only can save the image as the letter i, but not the actual number of i. Here is my code
if true
% load pf
for i=1:77
scatter(pf(:,(2*i-1)),pf(:,2*i),'.')
hold on
plot([0,100],[100,0])
h(i)=scatter(pf(:,(2*i-1)),pf(:,2*i),'.');
saveas(h(i),'i', 'pdf')
end end

采纳的回答

Iain
Iain 2013-6-19
try using num2str(i) instead of 'i'.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by