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
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File 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!