Clear Filters
Clear Filters

How do you plot a graph with various initial data?

3 views (last 30 days)
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.

Accepted Answer

Mischa Kim
Mischa Kim on 23 Feb 2014
Edited: Mischa Kim on 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 Comments
Alex
Alex on 23 Feb 2014
This is very useful thank you for your help, and have a nice day.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!