How do you plot a graph with various initial data?

3 次查看(过去 30 天)
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.

采纳的回答

Mischa Kim
Mischa Kim 2014-2-23
编辑:Mischa Kim 2014-2-23
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by