how do i resolve this ode45 problem

1 visualización (últimos 30 días)
Omar Nicolas García Gómez
Omar Nicolas García Gómez el 11 de Mayo de 2022
Editada: Jan el 11 de Mayo de 2022
I need to simulate a power multilevel inverter. For that i generate a vector (1x1000double) called Vo, represented by the blue signal:
The simulation is simple, it requires solving the following ecuation:
; with R=30 and L=0.0133 for t=[0 ,1/50].
when i try to solved it with "Vo" as a vector it returns an error, but then i try to transform this "Vo" vector into a function that fits in the time t=[0 1/50], with the following:
fo=50; mf=20;
t=linspace(0,1/fo,mf*fo);
Vof=@(t) Vo(1+ceil(t.*fo.*(length(t)-1));
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
the issue is that when i try to simulate the circuit the returned output it's a vector full of 0...
R=30; L=0.0133;
dio=@(t,io) (Vof(t)./L)-((R*io)/L);
tspan=[0 1/fo];
io0=0;
[tt,io]=ode45(dio,tspan,io0);
plot(tt,io),hold on
plot(t,Vof(t))
t = 1×1000
0 0.0000 0.0001 0.0001 0.0002 0.0002 0.0002 0.0003 0.0003 0.0004 0.0004 0.0004 0.0005 0.0005 0.0006 0.0006 0.0006 0.0007 0.0007 0.0008 0.0008 0.0008 0.0009 0.0009 0.0010 0.0010 0.0010 0.0011 0.0011 0.0012
how should i resolve this problem? any ideas?
PS: sorry for such weak explanation... first time asking.

Respuestas (1)

Jan
Jan el 11 de Mayo de 2022
Editada: Jan el 11 de Mayo de 2022
Your expression contains unbalances parentheses:
Vof=@(t) Vo(1+ceil(t.*fo.*(length(t)-1));
4 opening ( but only 3 closing ).
If this is fixed, the next error concerns "Vo". What is this?
Finally remember, that ODE45 is designed to integrate smoth functions. Your function does not look like it is differentiable. Then the step size controller of ODE45 can drive mad and the results can be dominated by rounding errors.
The integral of a piecewise constant function can be calculated by a sum more accurately and efficiently.
Prefer simple code. Compare these equivalent definitions:
dio = @(t,io) (Vof(t)./L)-((R*io)/L);
dio = @(t,io) Vof(t) / L - R * io / L;

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by