Only producing one graph rather then range of graphs.
5 次查看(过去 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')
0 个评论
采纳的回答
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
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!