using the title of excel spreadhseets to name graphs

1 visualización (últimos 30 días)
C.G.
C.G. el 12 de Feb. de 2021
Comentada: Geoff Hayes el 15 de Feb. de 2021
I have 39 excel spreadsheets which I have inputted into matlab and created a subplot of grpahs from.
I would like to name the respective graph based on the title of the excel spreadsheet. Is this possible?
%% plot all the sensitivty plots from the excel files
files = dir('*.xlsx');
num_files = length(files);
grainsleft = cell(length(files), 1);
for a = 1:num_files
grainsleft{a} = xlsread(files(a).name);
end
%% time steps
time = 1:30;
%% mass efflux vs. time
g = cell2mat(grainsleft);
%plot mass efflux
figure(1)
%create a
ax = gobjects(size(g));
for c = 1:size(g,1)
%create subplot
ax(c) = subplot(7,7,c);
bar(time,g(c,:), 0.01, 'EdgeColor', 'r');
hold on
grid on
xlabel('Time (S)');
ylabel('Mass Efflux');
end
linkaxes(ax)

Respuestas (1)

Geoff Hayes
Geoff Hayes el 12 de Feb. de 2021
It may be possible to add a title using title if you specifiy which axes the title should be applied to. For example, your code could include the line
title(ax(c), files(c).name)
assuming that the row of g corresponds to the correct file in files.
  2 comentarios
C.G.
C.G. el 15 de Feb. de 2021
Thank you for your repsonse.
what do you mean in your comment: 'assuming that the row of g corresponds to the correct file in files.'
Geoff Hayes
Geoff Hayes el 15 de Feb. de 2021
I'm assuming that there is a one-to-one correspondence of rows of g with the rows of files...so you can use c as an index in each such that the cth row of g comes from the cth file of files.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by