Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

ODE45

kelelkelel Posts: 3Member
[color=Blue]Hi everyone! This is my first time I approach to thi solver and a function. Infact I tried to solve my ODE, but it doesn't work.
Please, would you like to help me?
This is my functin:

N.B. i put the data in "datinuscita" file[/color]

function xp=sloshing(t,S)
%scrivi la funzione con il tempo e lo spostamento iniziale
load('datinuscita')

%xp=zeros(2,1);
%xp(1)=S(2)
xp=-omega_s^2*S+omega*mu/ms*d0*sin(omega*t)

end

[color=Blue]and the solver is:
[/color]
clc

tspan = linspace(0,20,101);
y0=[0,0]
[t,S] = ode45(sloshing, tspan, y0);


% Plot of the solution
plot(t,S(:,1))
xlabel('t')
ylabel('solution y')
title('sloshing vassel').

[color=Blue]Please, help me asap.

Thank you in advance

[/color]




Comments

  • giuggiug Posts: 217Member
    why "it doesn't work"? does it give you some error? please, attach some test input data so that I can try the code and check where is the problem.
  • kelelkelel Posts: 3Member
    Hello giug!! Many thanks to answer quickly!
    I have attached all my file. You can find the file to input data and a file where they are stored. There are also the function "sloshing" and the solver "sloshingsolv".

    This is the error messege:

    ??? Input argument "S" is undefined.

    Error in ==> sloshing at 7
    xp=-omega_s^2*S+omega*mu/ms*d0*sin(omega*t)

    Error in ==> sloshigosolv at 5
    [t,S] = ode45(sloshing, tspan, y0);

    Looking forword to hear from you!


  • giuggiug Posts: 217Member
    I think that one error is that you miss the function handle @.

    you have to call the function in this way (you can see the matlab help to verify it).

    [t,S] = ode45([b]@[/b]sloshing, tspan, y0);
Sign In or Register to comment.