How can I access different excel files and plot the data from each file on a single figure?
3 次查看(过去 30 天)
显示 更早的评论
Hi there,
I would like some assistance in accessing data from different excel files and then plotting the data from each of these files on a single figure.
Right now the code looks like this:
comparisons=input('How many graphs to plot?')
for i=1:comparisons
[a b c]=uigetfile('*xlsx','Select the Excel file')
[strain]=xlsread(a,'H1:H1000');
[stress]=xlsread(a,'J1:J1000');
figure (1)
hold on
plot(strain,stress,'b.')
xlabel('Strain')
ylabel('Stress')
legend(a)
hold off
i=i+1
end
I do not know how to include the name of all of the plots in the legend and I also do not know how to vary the plotting colour for each of the different plots. The number of plots that I require can vary from 1 plot on a certain figure to 5 plots on another figure.
Any help with this problem would be much appreciated
0 个评论
回答(1 个)
Image Analyst
2014-10-25
To plot in blue:
plot(strain,stress,'b.')
To plot in red:
plot(strain,stress,'r-')
Other colors are 'y', 'w', 'k', 'c', 'm', 'g'. You can get more with the 'Color' option of plot() - see the help. To plot up to six plots on one figure, use subplot(2,3,n)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!