mathlab, don't want debug this programme
1 view (last 30 days)
Show older comments
I need your help with respect to a program that does not want to debug ... could enlighten me on the problem, I'll be very grateful
%Fonction qui calcule la dérivée de x
function [ddelta domega dQ dpsiF dpsiq1 dvf] = derivative (t, x)
delta=x(1);
omega=x(2);
Q=x(3);
psiF=x(4);
psiQ1=x(5);
vf=x(6);
%introduction des paramètres
XqPrime = 0.25;
Xe=0.2;
Xq=0.7;
VR=1;
V0= 1.06;
G= 70;
Xd= 1.1;
QV= 0.1;
Z=0.82;
XdPrime=0.3;
omegaN=2*pi*50;
Tw= 2*omegaN;
Td0Prime= 7*omegaN;
TQ0Prime= 0.4*omegaN;
H= 4*omegaN;
T= 0.5*omegaN;
Tm= (omegaN/omega)*((Q/Z)^2)*((Q-QV)/(1-QV));
V=(((XdPrime*VR*cos(delta)+Xe*psiF/Td0Prime)/(Xe+XdPrime))^2+((XqPrime*VR*sin(delta)+Xe*psiQ1/TQ0Prime)/(Xe+ XqPrime))^2)^(1/2);
Te= ((XdPrime-XqPrime)*(VR)^2)/(2*(Xe+XdPrime)*(Xe+XqPrime))*sin(2*delta)-VR*psiQ1*cos(delta)/(TQ0Prime*(Xe+XqPrime))+VR*psiF*sin(delta)/(Td0Prime*(Xe+XdPrime));
RfIf= (Xe+Xd)*psiF/(Td0Prime*(Xe+XdPrime))-(Xd-XdPrime)*VR*cos(delta)/(Xe+XdPrime);
Rq1iq1= (Xe+Xq)*psiQ1/(TQ0Prime*(Xe+XqPrime))-(Xq-XqPrime)*VR*sin(delta)/(Xe+XqPrime);
ddelta = omega - omegaN; %1
domega = (omegaN)^2 *(Tm-Te)/(2*H); %2
dQ= (omegaN*(1-Q/Z)^2)/Tw;%3
dpsiF= (vf-RfIf)*omegaN;%6
dpsiq1 = (-Rq1iq1)*omegaN;%8
dvf= ((-vf+G*(V0-V))/T)*omegaN;%11
end
[T,X] =ode45(@derivative,[0 20],[0.55 317 0.81 2530 40.6 1.63]);
1 Comment
Jan
on 4 Mar 2013
It does not want to debug?! What could this mean?
Please mention what the problem is. The forum is excellent in solving problems, but we should at least be informaed, what the problem is.
Answers (3)
ChristianW
on 2 Mar 2013
Do you have the last line in a different m-file with a clear all at start? If so, clear all clears also breakpoints, try only clear without all.
2 Comments
Image Analyst
on 3 Mar 2013
Edited: Image Analyst
on 3 Mar 2013
It will not allow you to start debugging if there is a syntax error in your code.
Image Analyst
on 3 Mar 2013
The only time I've seen a program not let you debug it is when there is a syntax error somewhere in the file. So look for the error message or the little red line in the right margin to locate the syntax error and fix it.
0 Comments
Cedric
on 3 Mar 2013
Edited: Cedric
on 3 Mar 2013
You must have your function in an M-file called derivative.m without the call to ODE45, and make the latter from the command window or from another M-file. If you have the file derivative.m open in the editor, put the cursor on line 3 ( delta=x(1)) and press F12 to set a break point. Then, execute the call to ODE45 from the command window for example:
>> [T,X] = ode45(@derivative, [0 20], [0.55 317 0.81 2530 40.6 1.63]) ;
and you will see the debugger entering the function and stopping at line 3 (indicated with a green arrow).
I tested this bit and it worked perfectly. Now based on your work with the debugger (or by reading the error message that you get when you make the call to ODE45), you will realize that you have at least an issue with the length of your derivative (=1 when the initial condition has length 6).
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing 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!