フィルターのクリア

How do you plot a graph with various initial data?

3 ビュー (過去 30 日間)
Alex
Alex 2014 年 2 月 23 日
コメント済み: Mischa Kim 2014 年 2 月 23 日
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
  3 件のコメント
Alex
Alex 2014 年 2 月 23 日
This is very useful thank you for your help, and have a nice day.
Mischa Kim
Mischa Kim 2014 年 2 月 23 日
See code example above.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by