How to plot the solution?

1 回表示 (過去 30 日間)
Akhtar Jan
Akhtar Jan 2022 年 8 月 5 日
コメント済み: Akhtar Jan 2022 年 8 月 5 日
clc
close all
syms L
e = exp(sym(1));
lags = 0;
k1 = 3;
k_1 = 1;
k2 = 2.5;
k3 = 1;
k_3 = 1;
k4 = 2;
k5 = 1;
E1 = 1;
E2 = 2;
K1 = (k_1+k2)/k1;
K2 = (k_3+k4)/k3;
a = -(k5*E1)^2;
b = -k3*E2-(k5*E1)^(2)*(k_1+k_3+k2+k4+k1*E1);
c = k3*E2*(k_1+k2+k4+k1*E1)+(k5*E1)^(2)*(k1*k2*E1+(k_3+k4)*(k_1+k2+k1*E1));
d = k3*E2*k4*(k_1+k2)+k1*k3*E1*E2*(k2+k4)+k1*k2*k5^2*E1^3*(k_3+k4);
h = k5*E1;
f = k5*E1*(k_1+k_3+k2+k4+k3*E2);
g = k5*E1*(k_1+k2)*(k_3+k2+k3*E2);
eqn = (a*L^3+b*L^2-c*L-d)-(h*L^2+f*L+g)*e^(-L*lags);
vpasolve(eqn)
ans = 
  5 件のコメント
Akhtar Jan
Akhtar Jan 2022 年 8 月 5 日
clc
close all
lags = 0;
k1 = 3;
k_1 = 1;
k2 = 2.5;
k3 = 1;
k_3 = 1;
k4 = 2;
k5 = 1;
E1 = 1;
E2 = 2;
K1 = (k_1+k2)/k1;
K2 = (k_3+k4)/k3;
a = -(k5*E1)^2;
b = -k3*E2-(k5*E1)^(2)*(k_1+k_3+k2+k4+k1*E1);
c = k3*E2*(k_1+k2+k4+k1*E1)+(k5*E1)^(2)*(k1*k2*E1+(k_3+k4)*(k_1+k2+k1*E1));
d = k3*E2*k4*(k_1+k2)+k1*k3*E1*E2*(k2+k4)+k1*k2*k5^2*E1^3*(k_3+k4);
h = k5*E1;
f = k5*E1*(k_1+k_3+k2+k4+k3*E2);
g = k5*E1*(k_1+k2)*(k_3+k2+k3*E2);
fun = @(L) (a*L.^3+b*L.^2-c*L-d)-(h*L.^2+f*L+g).*exp(-L*lags);
% replaced e^ with exp, changed ^2 with .^2, and * to .*
L0 = -1.5;
L1 = fsolve(fun,L0);
L0 = -2.5;
L2 = fsolve(fun,L0);
plot((-2.5:0.1:-1),fun(-2.5:0.1:-1))
% look at the above code it is same as the given code it can plot the solution
% I need the same plot for my given code
Walter Roberson
Walter Roberson 2022 年 8 月 5 日

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

採用された回答

Torsten
Torsten 2022 年 8 月 5 日
syms L lags
e = exp(sym(1));
k1 = 3;
k_1 = 1;
k2 = 2.5;
k3 = 1;
k_3 = 1;
k4 = 2;
k5 = 1;
E1 = 1;
E2 = 2;
K1 = (k_1+k2)/k1;
K2 = (k_3+k4)/k3;
a = -(k5*E1)^2;
b = -k3*E2-(k5*E1)^(2)*(k_1+k_3+k2+k4+k1*E1);
c = k3*E2*(k_1+k2+k4+k1*E1)+(k5*E1)^(2)*(k1*k2*E1+(k_3+k4)*(k_1+k2+k1*E1));
d = k3*E2*k4*(k_1+k2)+k1*k3*E1*E2*(k2+k4)+k1*k2*k5^2*E1^3*(k_3+k4);
h = k5*E1;
f = k5*E1*(k_1+k_3+k2+k4+k3*E2);
g = k5*E1*(k_1+k2)*(k_3+k2+k3*E2);
eqn = (a*L^3+b*L^2-c*L-d)-(h*L^2+f*L+g)*e^(-L*lags);
lags_num = 0.01:0.01:0.18;
for i=1:numel(lags_num)
L_num(i) = double(vpasolve(subs(eqn,lags,lags_num(i))));
end
plot(lags_num,L_num)
  1 件のコメント
Akhtar Jan
Akhtar Jan 2022 年 8 月 5 日
Thank you sir ):-

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by