Filter löschen
Filter löschen

how can I let the string variable change in a loop

2 Ansichten (letzte 30 Tage)
xueqi
xueqi am 19 Jun. 2013
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

Akzeptierte Antwort

Iain
Iain am 19 Jun. 2013
try using num2str(i) instead of 'i'.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by