Only producing one graph rather then range of graphs.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
muhammad choudhry
am 17 Jul. 2022
Kommentiert: Star Strider
am 17 Jul. 2022
Hi,
I am trying to produce 45 graphs using the code below but it only producing one graph. what am I doing wrong. I also would like to save the graphs by its folder name basically there are 45 folders with specific folder name holding the csv file from which the data is read and plotted. your Help would save a lot of time.
Code:
close all; clear all; clc;
P = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_PIV\6-VectorSatistics\PlotOverLine';
S = dir(fullfile(P,'Run*Profile*','Export*.csv'));
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
M = readmatrix(F);
length=M(:,2);
U_x{k}=M(:,11);
U_y{k}=M(:,12);
U_m{k}=M(:,25);
plot (length,[U_x{k},U_y{k},U_m{k}],'-');
end
%Chart Representation
title('Velocities Across VFC (Below Outlet)');
xlabel('Distance(mm)');
ylabel('Velocities (m/s)');
legend('Velocities in x-direction','Velocities in y-direction','Resultant-Velocities')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 17 Jul. 2022
It appears that the last plot overplots all the previous plots. Perhaps adding a figure call will do what you want —
figure
plot (length,[U_x{k},U_y{k},U_m{k}],'-')
The rest of the code remians unchanged.
.
4 Kommentare
Star Strider
am 17 Jul. 2022
Save them with slightly different names, for example:
figure
plot (length,[U_x{k},U_y{k},U_m{k}],'-')
pfn = fullfile(P,sprintf('MyPlot_%03d.png', k));
saveas(gcf, pfn)
Change the string in the sprintf call to match the file name you want to save the figures with. This example saves each as .png files using the ‘k’ loop index to distinguish them, however that format is not the only option, and saving itt as .fig saves all the components of the figure, including the data, if that is desired. See the saveas documentation section on filename for details.
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Printing and Saving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!