Have problem about 2D graph
2 views (last 30 days)
Show older comments
I'm new in Matlab program, I want to plot 2D graph and got a problem in this line
"plot(X,Y,'--d','markersize',18,'linewidth',3.5);"
Please give me any advice. Thank you
%Graph 2
filename = 'weight_before_after.xlsx' ;
readdata = xlsread(filename);
X = readdata(7:10,5);
Y = readdata(35:38,5);
plot(X,Y,'--d','markersize',18,'linewidth',3.5);
xlabel('Mass before heating (g)','fontsize',30);
ylabel('Mass after heating (g)','fontsize',30);
axis equal;
set(gca,'ytick',[0:5:10]);
set(gca,'fontsize',26);
legend('Mass before heating','Mass after heating',4);
P.S. This is data from " weight_before_after.xlsx' "
0 Comments
Answers (1)
Image Analyst
on 20 Dec 2021
You're not using legend correctly -- get rid of the call to legend. It's not appropriate here. The rest looks fine. This works:
%Graph 2
% filename = 'weight_before_after.xlsx' ;
% readdata = xlsread(filename);
readdata = rand(38, 5); % Create sample data.
X = sort(readdata(7:10,5));
Y = readdata(35:38,5);
plot(X,Y,'--d','markersize',18,'linewidth',3.5);
xlabel('Mass before heating (g)','fontsize',30);
ylabel('Mass after heating (g)','fontsize',30);
axis equal;
set(gca,'ytick',[0:5:10]);
set(gca,'fontsize',26);
% legend('Mass before heating','Mass after heating');
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!