plotting data from data files and saving each plot through out each run of the loop

2 visualizzazioni (ultimi 30 giorni)
hello guys im trying to plot data from different dat files that have different parameters C (used to identity the file) throghout each run of the loop. For some reason im only getting one plot. Please help
below is what i did.
******************************************************************************************
Cpara=[0.02, 0.03, 0.04, 0.05, 0.06, 0.015, 0.025, 0.035, 0.045, 0.055];
for k = Cpara
file = importdata(strcat('A=0.12_B=2_C=',mat2str(k),'_hnull_2.1_t0.01e.dat'));
plot(file(:,1),file(:,2))
end

Risposta accettata

David K.
David K. il 12 Set 2019
If you wish to have all the plots on the same figure, you need to use
figure;
hold on
%The rest of your code
If you wish to have multiple figures you need to do
for k = Cpara
file = importdata(strcat('A=0.12_B=2_C=',mat2str(k),'_hnull_2.1_t0.01e.dat'));
figure
plot(file(:,1),file(:,2))
end
What you were doing was just replacing each plot with the next one instead of creating new figures.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by