Have problem about 2D graph

1 visualización (últimos 30 días)
Ratchapon Nilprapa
Ratchapon Nilprapa el 20 de Dic. de 2021
Respondida: Image Analyst el 20 de Dic. de 2021
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' "

Respuestas (1)

Image Analyst
Image Analyst el 20 de Dic. de 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');

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by