tspan= [0 10];
%initial Conditions
y0=[0.01 0.2];
opts = odeset('InitialStep',1e-2,'MaxStep',1e-2,'AbsTol', 1e-9);
[t,y]= ode45(@(t,y) EdoVL(t,y,m,k,c),tspan,y0,opts);
plot(t,y(1:length(t),1),'g');
grid on
xlabel('time');
ylabel('Displacement');
title('ODE45-Displacement Vs Time');
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0,
options, varargin);
Error in teste1 (line 22)
[t,y]= ode45(@(t,y) EdoVL(t,y,m,k,c),tspan,y0,opts);

2 件のコメント

Steven Lord
Steven Lord 2018 年 9 月 22 日
We can't tell with just what you've posted. Show the full text of the error message you received -- all the text displayed in red.
Marina Paschoal
Marina Paschoal 2018 年 9 月 22 日
編集済み: Walter Roberson 2018 年 9 月 22 日
>> VIBES1
Attempt to execute SCRIPT EdoVL as a function:
C:\Users\Marina\Documents\MATLAB\EdoVL.m
Error in VIBES1>@(t,y)EdoVL(t,y,m,k,c)
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in VIBES1 (line 41)
[t,y]= ode45(@(t,y) EdoVL(t,y,m,k,c),tspan,y0,opts);

サインインしてコメントする。

回答 (2 件)

Star Strider
Star Strider 2018 年 9 月 22 日
編集済み: Star Strider 2018 年 9 月 22 日

0 投票

In order for it to be a function, the first line of your ‘EdoVL.m’ file should be:
function dydt = EdoVL(t,y,m,k,c)
Try that. (This assumes that your derivative column vector is named ‘dydt’. Change the output to the appropriate variable name if it is named something else.)
See the documentation on function (link) for details.
Walter Roberson
Walter Roberson 2018 年 9 月 22 日

0 投票

You have C:\Users\Marina\Documents\MATLAB\EdoVL.m which is a script file -- that is, the first executable part of it is not the word "function" and is not the word "classdef". But the line
[t,y]= ode45(@(t,y) EdoVL(t,y,m,k,c),tspan,y0,opts);
tells us that you expect EdoVL to be a function with a minimum of 5 inputs.
Possibly you accidentally altered EdoVL.m to not start with a function. Or perhaps you have more than one EdoVL.m and C:\Users\Marina\Documents\MATLAB\EdoVL.m is earlier in your path than the EdoVL.m that you thought you were invoking.

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

タグ

質問済み:

2018 年 9 月 22 日

編集済み:

2018 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by