how can i bring 2 figures together?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
furkan aktürk
el 29 de Dic. de 2021
clc
clear
x = [0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5];
y = 2+exp((-x).^3);
plot(x,y)
clc
clear
x (1)= 0;
y (1)= 3;
h = 0.05;
for i = 1:10
y (i+1)= y(i)+(6*x(i)^2-3*x(i)^2*y(i));
x (i+1)= x(i)+h;
end
plot(x,y,'-')
xlabel('x')
ylabel('y')
i want to show these two codes graphs in one figure. how can i do it ? btw x of two y are same but i couldnt use for different folder.
0 comentarios
Respuesta aceptada
DGM
el 29 de Dic. de 2021
If you look, the two x vectors are not the same. They differ in length by 1. You can reuse the latter x if you want. Either way, you can plot mutliple things in an axes using hold.
x(1) = 0;
y2(1) = 3;
h = 0.05;
for i = 1:10
y2(i+1) = y2(i)+(6*x(i)^2-3*x(i)^2*y2(i));
x(i+1) = x(i)+h;
end
y1 = 2+exp((-x).^3);
plot(x,y1,'-'); hold on
plot(x,y2,'-')
xlabel('x')
ylabel('y')
0 comentarios
Más respuestas (1)
KSSV
el 29 de Dic. de 2021
Editada: KSSV
el 29 de Dic. de 2021
Read about hold on.
clc
clear
x1 = [0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5];
y1 = 2+exp((-x1).^3);
plot(x1,y1)
hold on
x (1)= 0;
y (1)= 3;
h = 0.05;
for i = 1:10
y (i+1)= y(i)+(6*x(i)^2-3*x(i)^2*y(i));
x (i+1)= x(i)+h;
end
plot(x,y,'-')
xlabel('x')
ylabel('y')
legend({'data1','data2'})
0 comentarios
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!