force input in ode

조회 수: 6 (최근 30일)
Bhanu Pratap Akherya
Bhanu Pratap Akherya 2021년 8월 24일
편집: darova 2021년 8월 29일
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:
F=xlsread('l&d.xlsx','O1:O300');
My main code looks something like:
y0=initial conditions
[tsol ysol]=ode15s('beam_function',[1:dt:T],y0);
plot(tsol,ysol);
whereas, my function code looks something like:
function [dy]=beam_function(t,y)
dy=[y(1:u-1);
inv(M)*(F-K*y(u:end)-C*y(1:u-1))]
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?

채택된 답변

darova
darova 2021년 8월 24일
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)),...)
end
function dy = beam_funciton(t,y,F)
  댓글 수: 6
Bhanu Pratap Akherya
Bhanu Pratap Akherya 2021년 8월 25일
No, I meant how to apply the current F matrix on only the last column of y in ODE. Right now it is being applied on all the columns of y.
darova
darova 2021년 8월 29일
편집: darova 2021년 8월 29일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by