Borrar filtros
Borrar filtros

How do you plot a graph with various initial data?

3 visualizaciones (últimos 30 días)
Alex
Alex el 23 de Feb. de 2014
Comentada: Mischa Kim el 23 de Feb. de 2014
The code below is work prefect, but how do I plot another initial data into one graph, such as I want to plot something when A = 3 etc but both initial data are in the same plot.
A=3.3
B=0.45
V=182.5
a=B; %%%formula for a
b=(A+sqrt(A.^2 - 4*(B.^2)))/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for b
c= -2*B; %%%formula for c
d=-2*A/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for d
K=(0:0.01:1);
alpha=(a+d-K.^2).^2 - (K.^2)*(V.^2)-4*(a*d - b*c - d*(K.^2))
beta=2.*K.*V.*(K.^2 - a + d)
re=1/2 *(a+d-K.^2+ sqrt((1/2 *((sqrt((alpha).^2 + (beta).^2))+ alpha))))
%A plot Re as a function of k
figure;
plot(K,re,'r');
title('Re as a function of k', 'fontsize', 10);
xlabel('K');
ylabel('Re');
grid on
I want my plot like this with 3 different initial data.

Respuesta aceptada

Mischa Kim
Mischa Kim el 23 de Feb. de 2014
Editada: Mischa Kim el 23 de Feb. de 2014
Something like this:
A_vec = [3.0; 3.3; 3.6]; % define your different A vals
figure
hold all % plot all in the same figure
for ii = 1:length(A_vec) % loop through all A vals
A = A_vec(ii); % assign iith val to A
B=0.45
V=182.5
a=B; %%%formula for a
b=(A+sqrt(A.^2 - 4*(B.^2)))/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for b
c= -2*B; %%%formula for c
d=-2*A/(A-sqrt(A.^2 - 4*(B.^2))); %%%formula for d
K=(0:0.01:1);
alpha=(a+d-K.^2).^2 - (K.^2)*(V.^2)-4*(a*d - b*c - d*(K.^2))
beta=2.*K.*V.*(K.^2 - a + d)
re=1/2 *(a+d-K.^2+ sqrt((1/2 *((sqrt((alpha).^2 + (beta).^2))+ alpha))))
%A plot Re as a function of k
plot(K,re);
end
title('Re as a function of k', 'fontsize', 10);
xlabel('K');
ylabel('Re');
grid on
  3 comentarios
Alex
Alex el 23 de Feb. de 2014
This is very useful thank you for your help, and have a nice day.
Mischa Kim
Mischa Kim el 23 de Feb. de 2014
See code example above.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by