How to plot the intermediat varaible Te,VPCC from a function called by ODE45 solver
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear all clc; % Time Tspan =[0 10]; X0=[0.7; 1.0151; 157 ];
options=odeset('RelTol',1e-3,'AbsTol',1e-6);
%solving the differential Equation [t,x]=ode45(@dvdt,Tspan,X0,options);
%Plotting the figures figure subplot(5,1,1) plot(t(:,1),x(:,1)) xlabel('t'); ylabel('Eprime'); title('Time Response ') grid on
subplot(5,1,2) plot(t(:,1),x(:,2)) xlabel('t'); ylabel('Delta') grid on
wradsec=x(:,3); wmech=(60*wradsec)/(2*pi); wpu=wmech/1500;
subplot(5,1,3) plot(t(:,1),wradsec) xlabel('t'); ylabel('Omega') grid on
% Plotting of Intermediate Variables as per Your Idea subplot(5,1,4) op= dvdt(t, x, 'flag'); plot(t(:,1),op(1,:)) xlabel('t'); ylabel('Vterminal') grid on
subplot(5,1,5) plot(t(:,1),op(2,:)) xlabel('t'); ylabel('ElectromagneticTorque') grid on
Function Code: function dv=dvdt(t,x,flag)
Xs=0.0754;Xr=0.0326;H=0.20; Rl=0.0083;Rcon=0.0089;Xl=0.033;Xcon=0.01789; Vdinf=1.0;Vqinf=0.0;wspu=157.0; T=0.7855;Xdash=0.1076;D=6.4165; Rt=Rl+Rcon;Xt=Xl+Xcon; xtrans=Xt+(D/Xr); detm=(Rt*Rt)+(xtrans*xtrans); J1=-xtrans;J2=-Rt;J3=-Rt;J4=xtrans; iq=(1/detm)*((J3*((x(1)*cos(x(2)))-Vqinf))+(J4*((-x(1)*sin(x(2)))-Vdinf))); id=(1/detm)*((J2*((-x(1)*sin(x(2)))-Vdinf))+(J1*((x(1)*cos(x(2)))-Vqinf))); Vq=(1/Xr)*((D*id)+(Xr*x(1)*cos(x(2)))); Vd=(-1/Xr)*((D*iq)+(Xr*x(1)*sin(x(2)))); Vdpc=(-Rcon*id)+(Xcon*iq)+Vdinf; Vqpc=(-Rcon*iq)-(Xcon*id)+Vqinf; VPCC=sqrt((Vdpc*Vdpc)+(Vqpc*Vqpc));% Intermediate Variable 1 t1=(Vq*cos(x(2)))-(Vd*sin(x(2))); t2=(Vq*sin(x(2)))+(Vd*cos(x(2))); t3=((Vd*cos(x(2)))+(Vq*sin(x(2)))); Te=(x(1)*t3/Xdash)% Intermediate Variable 2 Tm=1.0;
%The Diffenrential Equation
dv=[ (1/T)*((-Xs*x(1)/Xdash)+(((Xs-Xdash)/Xdash)*t1)); % My 1st Differential Equation
(x(3)-wspu)-(((Xs-Xdash)*t2) /(Xdash*T*x(1))); %My 2nd Differential Equation
(wspu/(2*H))*(Tm+Te)]; % My 3rd Differential Equation
if nargin == 3
dv = [VPCC;
Te];
end
It is giving the last value only.In workspace Te,VPCC is a 1x1 element.iT SHOULD BE AN ARRAY similar to x.I tried giving Te,VPCC Global,but in vein.Simulate the code ,Please help.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!