functionで関数を作る方法
Show older comments
下記のようなやり方で
蔵本モデルの微分方程式を解いたのですが、一番最初のfunctionの所でエラーが出てきてしまいます。
function dydt=kuramotomodel(t,y)
↑
エラー: このコンテキストでは関数定義はサポートされません。コードファイルで関数を作成してください。
コードファイルで関数を作成とはどのようなやり方なのでしょうか?
やり方分かるいましたら解決策を伺いたいです。
よろしくお願いいたします。
function dydt=kuramotomodel(t,y) K=10; N=3; omega=0.5; domega=zeros(1,N); for k=1:length(domega) domega(k)=omega; for m=1:length(domega) domega(k)=domega(k)+K/N*sin(y(m)-y(k)); end end dydt = [domega(1); domega(2); domega(3)];
function dydt=kuramotomodel(t,y)
K=10;
N=2;
omega=0.5;
domega=zeros(1,N);
for k=1:length(domega)
domega(k)=omega;
for m=1:length(domega)
domega(k)=domega(k)+K/N*sin(y(m)-y(k));
end
end
dydt = [domega(1); domega(2)];function dydt=kuramotomodel(t,y)
Accepted Answer
More Answers (1)
sz
on 13 Jul 2020
0 votes
Categories
Find more on プログラミング in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

