How do you plot a graph with various initial data?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Alex
am 23 Feb. 2014
Kommentiert: Mischa Kim
am 23 Feb. 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.
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 23 Feb. 2014
Bearbeitet: Mischa Kim
am 23 Feb. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!