Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Getting matlab to automatically produce graphs and the save them
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am new to Matlab so apologies if this seems simple.
I have a task where I have a number of folders containing .mat files and these files contain matrices.
I have folders 'test1' through to 'test50'. each folder contains 2 .mat files 'velocitydata.mat' and 'aerodynamicdata.mat'. Each .mat file has 3 matrices in the workspace Velocity,x,y,z and force,x,y,z.
I want to produce graphs for each folder showing plots of velocity in x over time and then save them in the relevant folder automatically. So for instance folder 'test1' will contain all the .mat files and the relevant .png graphs.
Is there anyway I can do this?
0 Commenti
Risposte (1)
Ameer Hamza
il 28 Apr 2020
Try something like this
files = dir('*/velocitydata.mat');
for i=1:numel(files)
filename = fullfile(files(i).folder, files(i).name);
l = load(filename);
plot(l.velocity_x);
[~, name] = fileparts(filename);
save_filename = fullfile(files(i).folder, [name, '.png']);
print(save_filename, '-r300'); % 300 ppi resolution
end
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!