how to use pulstran with ode45 function

1 view (last 30 days)
Hamza Khalil
Hamza Khalil on 27 Aug 2019
Commented: Hamza Khalil on 27 Aug 2019
I have tried to use pulstran with ode45 function but i got this problem ''DE_MDOF returns a vector of length 3005, but the length of initial conditions vector is 6. The vector returned by ODE_MDOF and the initial conditions vector must have the same number of elements.''
  2 Comments
Jon
Jon on 27 Aug 2019
Edited: Jon on 27 Aug 2019
The error is telling you that the function which you evaluate to get your derivatives (I assume this is ODE_MDOF) returns a different number of elements than the vector of initial conditions that you are supplying. They should of course be the same as you need to have a derivative for each state and an initial condition for each state. If you still can not figure out where things are going wrong that are resulting in the lengths of the two vectors being inconsistent, then please provide the relevant portions of your code.
Hamza Khalil
Hamza Khalil on 27 Aug 2019
thank you very much for your help im trying to put this function as force
f0=1;
Fs=10000;
Tf=5;
t=0:1/Fs:Tf-1/Fs;
td=0.012; % duty cycle
A0=1; % 10 Volts
F=0;
N=1000; % Number of points
for n=1:N
F=F+(1/n)*cos(n*2*pi*f0*t).*sin(n*pi*td);
end
F=F';
into the ODE45 function but i get ''returns a vector of length 3005'' error. however if i used f=50;
w= 2*pi*f;
A=1;
F= sin(w*t)
it will work just fine

Sign in to comment.

Answers (0)

Categories

Find more on Programming 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!