How can variables be passed to a function
1 回表示 (過去 30 日間)
古いコメントを表示
If I define a function in F.m file with the following:
function zp=F(x,z)
zp=zeros(2,1);
zp(1)=z(2);
zp(2)=a*sqrt(1+z(2)^2)+kx;
That is a function I want to evaluate by using:
[x,z]=ode45('F',[x0,xf],[z10,z20]);
I'm not sure how I can pass a and kx to that function before it is evaluated.
0 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 11 月 20 日
function zp=F(x,z,a,kx)
zp=zeros(2,1);
zp(1)=z(2);
zp(2)=a*sqrt(1+z(2)^2)+kx;
% ---------------------------------------------
[x,z]=ode45(@(x,z),F(x,z,a,kx),[x0 xf],[z10;z20]);
2 件のコメント
Azzi Abdelmalek
2013 年 11 月 20 日
Yes, remove a comma
[x,z]=ode45(@(x,z) F(x,z,a,kx),[x0 xf],[z10;z20]);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!