필터 지우기
필터 지우기

I keep getting an error. Help

조회 수: 4 (최근 30일)
SUNGJIN KIM
SUNGJIN KIM 2022년 3월 28일
답변: VBBV 2022년 3월 28일
%This progrem will use dfuncl.m
tspan = 0: 0.05: 8;
y = [0.4; 0;0];
[t , y]= ode23(@odefun, tspan, y);
plot (t, y(:, 1));
xlabel ('t');
ylabel ('y(1');
title ('problem 2.187');
function f = odefun( ~ , y )
u = 0.5;
k = 100;
m = 5;
f=zeros(2,1);
f(1) = y(2);
f(2) = -u*9.81*sign(y(2))-k*y(1)/m;
end
---------------------------------------------------------------
An error occurred while using the note: odarguments (line 95)
ODEFUN returns a vector of length 2, but the initial condition vector is of length 3.
The vector returned by ODEFUN and the initial condition vector must have the same number of elements.
Error occurred: ode23 (line 114)
odarguments(FcnHandlesUsed, solver_name, ode, tspan, y0,
options, varargin);
Error occurred: pr187 (line 5)
[t , y]= ode23(@odefun, tspan, y);

답변 (1개)

VBBV
VBBV 2022년 3월 28일
tspan = [0:0.05: 8];
y = [0.4; 0];
[t , y]= ode45(@odefun, tspan, y);
plot (t, y(:, 1));
xlabel ('t');
ylabel ('y(1');
title ('problem 2.187');
function f = odefun( ~ , y )
u = 0.5;
k = 100;
m = 5;
f=zeros(2,1);
f(1) = y(2);
f(2) = -u*9.81*sign(y(2))-k*y(1)/m;
end
check with ode45

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by