フィルターのクリア

Nonscalar arrays of function handles are not allowed; use cell arrays instead.

3 ビュー (過去 30 日間)
a_vec=[0.020 0.025 0.030];
for i=1:length(a_vec)
dP_dt_1(i)=@(P) (a_vec(i).*P)-(b.*P.^2);
[t_ode45_vec_1,y_ode45_vec_1] = ode45(@(P,t) dP_dt_1(t),[t_0 t_max],P_0);
figure(5)
plot(t_ode45_vec_1,y_ode45_vec_1)
hold on
end
Hi everyone, when I try to run this piece of code, I get an error :
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
How can I resolve this error?
Thanks in advance!

採用された回答

James Tursa
James Tursa 2020 年 4 月 28 日
You don't need to create an array of function handles. You just need to construct one function handle to use for that iteration. So just
dP_dt_1 = @(P) (a_vec(i).*P)-(b.*P.^2);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by