Only producing one graph rather then range of graphs.

1 次查看(过去 30 天)
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')

采纳的回答

Star Strider
Star Strider 2022-7-17
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 个评论
Star Strider
Star Strider 2022-7-17
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.
.

请先登录,再进行评论。

更多回答(0 个)

类别

Find more on 2-D and 3-D Plots 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!

Translated by