Plotting selective Excel Data in Matlab

2 次查看(过去 30 天)
I have two small issues:
1: I want to use the excel sheet name as a tittle name of each plotted figure. 2: If the number of figures are more that the array given in subplot it generates error. e.g. if i=10 and the subplot array is 3x2 then it only generate the pdf with 6 figures and doesn't generate the the remaining 4.
I am totaly new to matlab . please ignore if the question sounds stupid.
Here is my code clear; clc; XLfile = dir; number_of_files = length(XLfile); index = 3;
for index = 3:number_of_files
filename = XLfile(index).name;
for i=1:10
x=xlsread(filename,i,'C2:C10000');
y=xlsread(filename,i,'D2:D10000');
subplot(3,2,i);
plot(x,y,'b')
xlabel('Shear strain (%)','FontSize', 8)
ylabel('Shear stress ratio (\tau^{\prime}/\sigma_{vo}^{\prime})','FontSize', 8)
title(filename(1:end-4))
set(gcf, 'PaperPosition', [0 0 5 8]);
set(gcf, 'PaperSize', [5 8]);
saveas(gcf,[filename(1:end-4),'pdf'])
end
figure
end

回答(1 个)

Titus Edelhofer
Titus Edelhofer 2016-1-18
Hi,
I'm not sure where the problem with the title is, because calling
title(filename(1:end-4))
should work.
Regarding the problem with 6 subplots and the loop of 10: it is not clear to me what you expect? You use subplot(3,2,i), so that the output looks like
[plot1] [plot2]
[plot3] [plot4]
[plot5] [plot6]
But your loop runs from 1 to 10. So when the loop is at 7, what do you expect to happen?
You could e.g. use subplot(4,3,i), this way you would see all 10 plots ...
Titus

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by