how to show only selective legend in the graph

7 vues (au cours des 30 derniers jours)
AL
AL le 18 Avr 2023
Commenté : AL le 18 Avr 2023
Can it be possible to show only Undeformated and data12?
x = [0 0 0 140 140 140 280 280 280 420 440 420 515.190000000000 577.690000000000 640 493.590000000000 556.080000000000 618.590000000000 466.790000000000 529.290000000000 591.790000000000 440 502.500000000000 565 440 505.170000000000 570.350000000000 456.080000000000 521.250000000000 586.420000000000 472.150000000000 537.330000000000 602.500000000000 488.230000000000 553.400000000000 618.580000000000 515.190000000000 577.690000000000 640.190000000000 493.590000000000 556.090000000000 618.590000000000 466.790000000000 529.290000000000 591.790000000000 440 502.500000000000 565];
y = [-22 0 22 -22 0 22 -22 0 22 -22 0 22 316.610000000000 316.610000000000 316.610000000000 236 236 236 136 136 136 22 22 22 0 0 0 0 0 0 0 0 0 0 0 0 -316.610000000000 -316.610000000000 -316.610000000000 -236 -236 -236 -136 -136 -136 -22 -22 -22];
z = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 50 50 100 100 100 150 150 150 0 0 0 0 0 0 0 0 0 0 0 0];
scatter3(x,y,z);
%point 1 2 3 6 9 12 22 19 16 13 14 15 18 21 24 27 4 45 42 39 38 37 40 43 46
%10 7 4 1
X1 = 0.01*[x(1),x(2),x(3),x(6),x(9),x(12),x(22),x(19),x(16),x(13),x(14),x(15),x(18),x(21),x(24),x(27),x(48),x(45),x(42),x(39),x(38),x(37),x(40),x(43),x(46),x(10),x(7),x(4),x(1)];
Y1 = 0.01*[y(1),y(2),y(3),y(6),y(9),y(12),y(22),y(19),y(16),y(13),y(14),y(15),y(18),y(21),y(24),y(27),y(48),y(45),y(42),y(39),y(38),y(37),y(40),y(43),y(46),y(10),y(7),y(4),y(1)];
% points 42 41 40
X2 = 0.01*[x(42),x(41),x(40)];
Y2 = 0.01*[y(42),y(41),y(40)];
% points 45 44 43
X3 = 0.01*[x(45),x(44),x(43)];
Y3 = 0.01*[y(45),y(44),y(43)];
% points 21 20 19
X4 = 0.01*[x(21),x(20),x(19)];
Y4 = 0.01*[y(21),y(20),y(19)];
% points 18 17 16
X5 = 0.01*[x(18),x(17),x(16)];
Y5 = 0.01*[y(18),y(17),y(16)];
% points 11 8 5 2
X6 = 0.01*[x(11),x(8),x(5),x(2)];
Y6 = 0.01*[y(11),y(8),y(5),y(2)];
% 27 26 25 28 31 34 35 36 33 30 37
X7 = 0.01*[x(27),x(26),x(25),x(28),x(31),x(34),x(35),x(36),x(33),x(30),x(27)];
Z7 = 0.01*[z(27),z(26),z(25),z(28),z(31),z(34),z(35),z(36),z(33),z(30),z(27)];
% points 30 29 28
X8 = 0.01*[x(30),x(29),x(28)];
Z8 = 0.01*[z(30),z(29),z(28)];
% points 33 32 31
X9 = 0.01*[x(33),x(32),x(31)];
Z9 = 0.01*[z(33),z(32),z(31)];
% points 48 47 46
X10 = 0.01*[x(48),x(47),x(46)];
Y10 = 0.01*[y(48),y(47),y(46)];
% points 24 23 22
X11 = 0.01*[x(24),x(23),x(22)];
Y11 = 0.01*[y(24),y(23),y(22)];
for i=1:10
Z1 = [Z(1,i),Z(2,i),Z(3,i),Z(6,i),Z(9,i),Z(12,i),Z(22,i),Z(19,i),Z(16,i),Z(13,i),Z(14,i),Z(15,i),Z(18,i),Z(21,i),Z(24,i),Z(27,i),Z(48,i),Z(45,i),Z(42,i),Z(39,i),Z(38,i),Z(37,i),Z(40,i),Z(43,i),Z(46,i),Z(10,i),Z(7,i),Z(4,i),Z(1,i)];
Z_1 = 0.01*[z(1),z(2),z(3),z(6),z(9),z(12),z(22),z(19),z(16),z(13),z(14),z(15),z(18),z(21),z(24),z(27),z(48),z(45),z(42),z(39),z(38),z(37),z(40),z(43),z(46),z(10),z(7),z(4),z(1)];
Z2 = [Z(42,i),Z(41,i),Z(40,i)];
Z3 = [Z(45,i),Z(44,i),Z(43,i)];
Z4 = [Z(21,i),Z(20,i),Z(19,i)];
Z5 = [Z(18,i),Z(17,i),Z(16,i)];
Z6 = [Z(11,i),Z(8,i),Z(5,i),Z(2,i)];
Y7 = [Z(27,i),Z(26,i),Z(25,i),Z(28,i),Z(31,i),Z(34,i),Z(35,i),Z(36,i),Z(33,i),Z(30,i),Z(27,i)];
Y8 = [Z(30,i),Z(29,i),Z(28,i)];
Y9 = [Z(33,i),Z(32,i),Z(31,i)];
Z10 = [Z(48,i),Z(47,i),Z(46,i)];
Z11 = [Z(24,i),Z(23,i),Z(22,i)];
figure(i)
%plot3(X1,Y1,Z1,'r',X2,Y2,Z2,'r',X3,Y3,Z3,'r',X4,Y4,Z4,'r',X5,Y5,Z5,'r',X6,Y6,Z6,'r',X7,Y7,Z7,'r',X8,Y8,Z8,'r',X9,Y9,Z9,'r',X10,Y10,Z10,'r',X11,Y11,Z11,'r')
plot3(Y1,X1,Z1,'r',Y2,X2,Z2,'r',Y3,X3,Z3,'r',Y4,X4,Z4,'r',Y5,X5,Z5,'r',Y6,X6,Z6,'r',Y7,X7,Z7,'r',Y8,X8,Z8,'r',Y9,X9,Z9,'r',Y10,X10,Z10,'r',Y11,X11,Z11,'r')
%legend('Defomation')
hold on
plot3(Y1,X1,Z_1,'g--')
xlabel({'X',"(Unit: m)"},'Fontsize',12); ylabel({'Y',"(Unit: m)"},'Fontsize',12);zlabel({'Z',"(Unit: m)"},'Fontsize',12);
title(["Mode " + num2str(i)],FontSize=12);
xlim([-3.5 3.5]);
ylim([0 7]);
zlim([-2 3]);
%legend('Undefomation')
end
clear X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11
clear Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 Y11
clear Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9 Z10 Z11

Réponse acceptée

Sam Chak
Sam Chak le 18 Avr 2023
Hi @AL
On the basic, you can do this:
x = linspace(-pi, pi, 3601);
y1 = sin(x);
y2 = cos(x);
y3 = 1*(x);
plot(x, [y1' y2' y3']), grid on
legend('sin(x)', '', '1x')
  1 commentaire
AL
AL le 18 Avr 2023
Worked perfectly! Thank you so much @Sam Chak. Have wonderful week.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by