Not enough input arguments for my ode15s solver
古いコメントを表示
I got my code following
clear
load("BurgersMatrices_2022.mat");
T = 3; nt = 600; tspan = linspace(0,T,nt);
options = odeset('Mass',E);
x0 = [0; x0b ; 0];
[tout,xout] = ode15s(prime,tspan,x0,options);
function out = prime(x)
load("BurgersMatrices_2022.mat");
J = nonzeros(A); A1 =J(1) ; A2 = J(2);
J = nonzeros(H); H2 = J(2); H3 = J(1);
for j = 2:1025
one(j) = A1*x(j) + A2*(x(j-1)+x(j+1));
two(j) = H2*(x(j+1))^2 + H3*(x(j-1))^2;
out(j) = one(j)-0.5*two(j);
end
out(1026) = 0;
out = out';
end
where my x0b is a 1024*1 vector and x0 vector is 1026*1. E is a mass matrix for E (dx/dt) = f(x). I got the error "Not enough input arguments." saying
Error in HW1_P1>prime (line 21)
one(j) = A1*x(j) + A2*(x(j-1)+x(j+1));
Error in HW1_P1 (line 14)
[tout,xout] = ode15s(prime,tspan,x0,options);
i'm not sure what's wrong with it, could anyone help me with this? Thank you.
採用された回答
その他の回答 (1 件)
Torsten
2022 年 10 月 19 日
options = odeset('Mass',E);
E is not defined.
x0 = [0; x0b ; 0];
x0b is not defined.
[tout,xout] = ode15s(prime,tspan,x0,options);
Must read
[tout,xout] = ode15s(@(t,y)prime(y),tspan,x0,options);
load("BurgersMatrices_2022.mat");
We don't know the content of "BurgersMatrices_2022.mat"
for j = 2:1025
one(j) = A1*x(j) + A2*(x(j-1)+x(j+1));
two(j) = H2*(x(j+1))^2 + H3*(x(j-1))^2;
out(j) = one(j)-0.5*two(j);
end
out(1) is not defined.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


