How to set user defined directory to save multiple figures?
1 view (last 30 days)
Show older comments
Hello, I am importing excel spread sheet data and creating multiple figures from the data. I have code written to create a subfolder to save these figures into and I would like to write the code for the saveas function to save the figures created into that subfolder. Also, when importing the data I create a pathname that has the name of the excel file plus its respective extension. I would like to write an mkdir('Figure') to include the pathname of the excel in the folder's name that is being created. Ex: pathname=Pressure Data 1.xls and so the folder created by mkdir('Figure for........') would include the pathname making it Figure for Pressure Data 1 code is listed below:
clear all; close all;
disp(' ');
disp('Data must either be .xls or .xlsx formatting');
disp(' ');
[filename, pathname] = uigetfile('*.*');
xfile = fullfile(pathname, filename);
pres = xlsread(xfile);
pres=double(pres(:,1));
t=1:1:length(pres);
Make directory folder to save figures in
mkdir('Figures');
figure;
plot(t,pres);
xlabel('Time'); ylabel('Presure (psig)'); title('Pressure Cycle Data');
saveas(gcf,'Pressure Cycle Data','pdf');
close Figure 1;
[ymax, imax, ymin, imin]=extrema(pres);
figure;
plot(t,pres);
title('Location of Critical Points');
hold on;
plot(t(imax),ymax,'ro',t(imin),ymin,'ro');
hold off;
saveas(gcf,'Location of Critical Points','pdf');
close Figure 1;
ext=sig2ext(pres);
rf=rainflow(ext);
figure;
rfhist(rf,50,'amp1');
h=vline(mean(rf(1,:)),'r',['Mean Amplitude = ' num2str(mean(rf(1,:)))]);
saveas(gcf,'Rainflow Amplitude Histogram','pdf');
close Figure 1;
figure;
rfhist(rf,50,'mean');
h=vline(mean(rf(2,:)),'r',['Average Mean = ' num2str(mean(rf(2,:)))]);
saveas(gcf,'Rainflow Mean Histogram','pdf');
close Figure 1;
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!