functionで関数を作る方法
Afficher commentaires plus anciens
下記のようなやり方で
蔵本モデルの微分方程式を解いたのですが、一番最初の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)
Réponse acceptée
Plus de réponses (1)
sz
le 13 Juil 2020
0 votes
Catégories
En savoir plus sur プログラミング dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

