How to solve ode113 with a time independent load vector?

I'm trying to solve ode113 for a wind turbine which is charged with a wind load. This wind load is calculated from another program and is a vector of random numbers which discribes the load over time in a step of 0.01 s. The problem is that ode113 usually is subjected to a function which is dependent on time. How can I manage to solve ode113 but at the same time take into consideration the time course of my load vector?

 Accepted Answer

The example "ODE with Time-Dependent Terms" under
should solve your problem.
Best wishes
Torsten.

10 Comments

Thank you, but now I have another problem. The ode output t has always the same size, a vector of size 11x1, even if I change my tspan... my load vector is changed automatically every time, since it is a random vector. How is that possible? Should I send the code??
Please include the relevant part of your code.
Best wishes
Torsten.
This is the main code:
ta=0;
te=10;
deltat=0.001;
elem=30;
ld=3;
nodes=elem+1;
u0=zeros(nodes*ld,1);
P=zeros(nodes*ld,1); %Load vector per node
Pt = linspace(ta, te, (te+deltat)/deltat); %time vector with te*100+1 Inputs
m=length(Pt);
F=random('Normal',0,10,length(Pt),1);
for i=1:m
P(end-2:end,1)=0;
P(end-2:end,1) = P(end-2:end,1)+F(i);
A(:,i)=P;
end
tspan = [ta te];
ic = 1;
opts = odeset('RelTol',1e-2,'AbsTol',1e-4);
[t,u]=ode45(@(t,u) fu1(t,u,u0,Pt,A),[ta te],u0,opts);
And than for fu1:
function u=fu1(t,u,u0,Pt,A)
A=A.';
A = interp1(Pt,A,t); % Interpolate the data set (P,A) at time t
A=A.';
n=size(A);
m=n(2);
for i=1:m
u=zeros(nodes*ld*2,1);
u(1:nodes*ld,1)=u0; % 1:nodes*ld Displacement, nodes*ld+1:nodes*ld*2 Velocity
du=zeros(nodes*ld*2,1); % 1:nodes*ld Velocity, nodes*ld+1:nodes*ld*2 Acceleration
du(1:nodes*ld,1)=u(nodes*ld+1:nodes*ld*2,1); % du(1)=u(2)
du(nodes*ld+1:end,1)=M\(A(:,i)-K*u(1:nodes*ld,1)-C*u(nodes*ld+1:nodes*ld*2,1)); %Acceleration %du(2)=M\(P-K*u(1)-C*u(2))
u(1:nodes*ld,1)=K\(A(:,i)-M*du(nodes*ld+1:nodes*ld*2,1)-C*u(nodes*ld+1:nodes*ld*2,1)); %Displacement
u(nodes*ld+1:nodes*ld*2,1)=C\(A(:,i)-M*du(nodes*ld+1:nodes*ld*2,1)-K*u(1:nodes*ld,1)); %Velocity
%ddu=du(nodes*ld+1:nodes*ld*2,1);
%du=u(nodes*ld+1:nodes*ld*2,1);
u=u(1:nodes*ld,1);
end
end
M, K and C are inputs from again another function... they have the size nodes*ldxnodes*ld, where ld stands for degrees of freedom... Does that help in some way or is it to complex?? Thanks a lot!!
I can change tspan, the load or my degrees of freedom, t will always remain a 11x1 vector...
Hey, there is a problem with the code I just send you... since t is zero at first it interpolates my load array A, so that there isn't any load left... A becomes a nodes*ldx1 vector, so it discribes only ONE load at a specific time! Do you have an idea how I can solve this problem? How can I manage, that t is solved for the ODE but at the same time is using my load vector as an input?? Thanks again!
The ODE-integrator needs the load at the specific time t (t is a scalar, one value). That's why I gave you the link in my first response: you have to interpolate the load vector A at the time required by the ODE-integrator.
Best wishes
Torsten.
Hey Torsten, sorry for writing you again, but I don't understand, what time the ODE-integrator requires... Doesn't it calculate solutions for specific times, which I don't know it advance depending on the load?? Thanks for your answers and in advance!!
Hey, I think I solved the problem! Thanks :)

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!