basic question on creating a function and plotting
古いコメントを表示
Hello everyone
i have the expression to calculate: Ke=K0*e*a*(a-1)/(1+e-a*e)
K0, e are known values and a is my variable so i create the function Ke(a).
But using the command: Ke1=inline('K0*e*a*(a-1)/(1+e-a*e)') does not apply the given values of K0 and e, that is, it returns the function Ke1(K0,e,a), instead of Ke1(a)
I am using MATLAB 2009b
Thanks in advance
採用された回答
その他の回答 (1 件)
Amir
2014 年 8 月 14 日
Please try this code and compare the results:
disp('%%%%% Run1 %%%%%%');
syms K0 e a;
F=K0*e*a*(a-1)/(1+e-a*e);
Ke1=matlabFunction(F)
disp('%%%%% Run2 %%%%%%');
K0=2; e=2.71;
syms a;
F=K0*e*a*(a-1)/(1+e-a*e);
Ke1=matlabFunction(F)
Results are as below:
%%%%% Run1 %%%%%%
Ke1 =
@(K0,a,e)(K0.*a.*e.*(a-1.0))./(e-a.*e+1.0)
%%%%% Run2 %%%%%%
Ke1 =
@(a)(a.*(a-1.0).*(-2.71e2./5.0e1))./(a.*(2.71e2./1.0e2)-3.71e2./1.0e2)
カテゴリ
ヘルプ センター および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!