force input in ode

8 views (last 30 days)
Bhanu Pratap Akherya
Bhanu Pratap Akherya on 24 Aug 2021
Edited: darova on 29 Aug 2021
i have a set of values for the force term "F" (in the equation my"+cy'+ky=F) saved in an excel file which i have recalled using:
My main code looks something like:
y0=initial conditions
[tsol ysol]=ode15s('beam_function',[1:dt:T],y0);
whereas, my function code looks something like:
function [dy]=beam_function(t,y)
The problem is that i want to recall each value of F at different time steps but i dont know how to do that, can anyone guide me?
Note: F here is not time dependent rather it has been taken from results obtained from a simulation software. Then what should be my approach?

Accepted Answer

darova on 24 Aug 2021
You need to pass F into your ode function. Read more: LINK
for i = 1:length(F)
[t,y] = ode45(@(t,y)beam_function(t,y,F(i)),...)
function dy = beam_funciton(t,y,F)
darova on 29 Aug 2021
Edited: darova on 29 Aug 2021
Maybe you need another ode function
function [dy]=beam_function(t,y)
n = numel(y);
dy(n/2) = y(end);
dy(end) = inv(M)*(F-K*y(end)-C*y(end));
And solve it separately

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!