error using ode23
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
These are my errors im not sure what is causing it.
Error in odearguments (line 90) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode23 (line 114) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
code for ode(where t is a vector I've defined as linspace(0,0.2,10000)):
options=odeset('Maxstep', 1e-5);
[t,x]= ode23(@boost,[0:1e-7:0.2], [0 0], options);
3 Commenti
Risposte (1)
Star Strider
il 21 Gen 2018
You have not passed ‘T’ and ‘d’ to ‘boost’ as extra parameters, nor have you defined them in the function. Since ‘boost’ is not an anonymous function, it will not get them from your workspace. You have to pass them as extra arguments if you want ‘boost’ (and ‘pwm’) to use them.
I cannot run your code to test it, since I do not have the ‘pwm’ function. I cannot find it in the current online documentation.
That aside, assuming that the various conditions in your if blocks create discontinuities, note that the derivatives do not exist at discontinuities, so the ODE integration functions will have significant problems with them.
3 Commenti
Star Strider
il 21 Gen 2018
First, using global variables are considered very poor programming practice. It can be extremely difficult to debug code that uses them. Other functions can alter them internally, creating chaos in your code.
Second, functions have their own workspaces, so unless you also declare them as global in the functions, the functions do not know they exist.
So instead, pass them as arguments to your functions, so you know what values your functions are receiving, and you know that they are receiving the values.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!