Need help in m file [ Solved ] - Page 1
Forum section: electronics / projects

author: abrarbaig
author_rank: Contributor
timestamp: March 03, 2018, 06:07:16 pm
content: Here is my another m file. When I run it, I get this error:Error in dfig (line 78)Ps(i)= 1.5*(Rs*ids.^2 + Rs*iqs.^2 + ws*Fs.*iqs);Code:% DFIG parameters --> rotor parameters referred to the stator sidef = 50;Ps = 2e6;n = 1500;Vs = 690;Is = 1790;%Tem = 12732;p = 2;u = 1/3;Vr = 2070;smax = 1/3;Vr_stator = Vr*smax*u;Rs = 2.6e-3;Lsi = 0.087e-3;Lm = 2.5e-3;Rr = 2.9e-3;Ls = Lm + Lsi;Lr = Lm + Lsi;Vbus = Vr_stator*sqrt(2);sigma = 1 - Lm^2 /(Ls*Lr);Vs = 690*sqrt(2/3);ws = f*2*pi;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Maximum and minimum speedswt_nom = 18;wt_min = 9;% Gerabox ratioN = 100;% Torque and speed arrayswt = [0.9425,0.9425,0.9425,0.9424,1.0476,1.1429,1.2381,1.3333,1.4286,...1.5235,1.6190,1.7143,1.8095,1.8850,1.8850,1.8850,1.8850,1.8850,...1.8850,1.8850,1.8850];Torque = -1e6*[0.0501,0.1164,0.1925,0.2696,0.3262,0.3883,0.4557,0.5285,...0.6067,0.6902,0.7792,0.8736,0.9733,1.0894,1.2474,1.2745,...1.2745,1.2745,1.2745,1.2745,1.2745];i = 0;Temm = Torque/N;wmm = wt*(60/2/pi)*N;sss = (1500 - wmm)/1500;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Qs = 0%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Ref_Qs_ = 0*ones(size(sss));i = 0;for ss = sss,i=i+1;for Tem= Temm(i), i = i+1;Ref_Qs = Ref_Qs_(i);Wm = ws*(1-ss);s(i) = ss;endA = ws*ws*Lm*Lm;B = 4*Rs^2*Tem*ws/3 - ((Vs)^2);C = 4*Rs^2/(9*Lm^2)*((Ref_Qs.^2)/(ws^2)*(Tem.^2)/(p^2));X1 = ( -B + sqrt(B.^2-4*A.*C))./(2*A);X2 = (-B-sqrt(B.^2-4*A.*C))./(2*A);Fs = Lm*sqrt(X1);Fs(i) = Fs;% stator currentsfor ids = 2*Ref_Qs./(3*ws*Fs), i=i+1;for iqs = 2*Tem./(3*p*Fs), i=i+1;endendIs(i) = sqrt(ids.^2+ iqs.^2);% stator voltagesfor uds = Rs*ids,i = i+1;for uqs = Rs*iqs + ws*Fs,i=i+1;endendUs(i) = sqrt(uds.^2 + uqs.^2);% satator powerPs(i)= 1.5*(Rs*ids.^2 + Rs*iqs.^2 + ws*Fs.*iqs);Qs(i) = Ref_Qs, i=i+1;Mod_Ss = sqrt(Ps.^2 + Qs.^2);% Rotor currentsfor idr = -Ls*ids/Lm + Fs/Lm, i = i+1;for iqr = -Ls*iqs/Lm, i = i+1;endendIr(i)=sqrt(idr.^2 + iqr.^2);% wrwr = ws*ss;% rotor voltagesudr = Rr*idr - Lr*wr.*iqr - Lm*wr.*iqs;uqr = Rr*iqr + Lr*wr.*idr + Lm*wr.*ids;Vr(i) = sqrt(udr^2 + uqr^2);% Rotor powerPr(i) = 1.5*(udr.*idr + uqr.*iqr);Qr(i) = 1.5*(uqr.*idr - udr.*iqr);Mod_Sr = sqrt(Pr.^2 + Qr.^2);% stator fluxFsd = Ls*ids + Lm*idr;Fsq = Ls*iqs + Lm*iqr;Fs(i) = sqrt(Fsd^2 +Fsq^2);% rotor fluxFrd = Lr*idr + Lm*ids;Frq = Lr*iqr + Lm*iqs;Fr(i) = sqrt(Frd.^2 + Frq.^2);% mechanical powerPmec(i) = Tem*Wm/p;% efficiancyif Pmec(i) >= 0R(i) = Pmec(i) / (Ps(i) + Pr(i)); % motor modeelseR(i) = (Ps(i) + Pr(i))/Pmec(i); % motor modeendendfigure(1)subplot(3,3,1)hold onplot(wmm,Temm,'r',wmm,Temm,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Tem (NM)','fontsize',14);xlim([700,2000]);subplot(3,3,2)hold onplot(wmm,Ps + Pr,'r',wmm,Ps + Pr, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pt (W)','fontsize',14);xlim([700,2000]);subplot(3,3,3)hold onplot(wmm,Pr,'r',wmm,Pr, 'ogr','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pr (W)','fontsize',14);xlim([700,2000]);subplot(3,3,3)hold onplot(wmm,Ps,'r',wmm,Ps, 'ogr','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ps & Pr(W)','fontsize',14);xlim([700,2000]);subplot(3,3,4)hold onplot(wmm,Is,'r',wmm,Is, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Is (A)','fontsize',14);xlim([700,2000]);subplot(3,3,5)hold onplot(wmm,Ir,'r',wmm,Ir, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ir (A)','fontsize',14);xlim([700,2000]);subplot(3,3,6)hold onplot(wmm,Vr,'r',wmm,Vr, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Vr & Vs (V)','fontsize',14);xlim([700,2000]);subplot(3,3,7)hold onplot(wmm,Qs,'r',wmm,Qs, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qs (VAR)','fontsize',14);xlim([700,2000]);subplot(3,3,8)hold onplot(wmm,Qr,'r',wmm,Qr, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qr (VAR)','fontsize',14);xlim([700,2000]);subplot(3,3,9)hold onplot(wmm,R,'r',wmm,R, 'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Efficiency (pu)','fontsize',14);xlim([700,2000]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% idr = 0i=0;for ss = sss,i = i + 1;Tem = Temm(i);Wm = ws*(1 - ss);s(i) = ss;A = ws^2*Lm^2 + (Rs*Lm/Ls)^2;B = 4*Rs*Tem*ws/3/p -((Vs)^2);C = 4*Rs^2*Tem^2 / (9*p^2*Lm^2);X1 = (-B + sqrt(B.^2 - 4*A.*C))./(2*A);X2 = (-B - sqrt(B.^2 - 4*A.*C))./(2*A);ims = sqrt(X1);ims(i) = ims;Fs = ims*Lm;% rotor currentsidr = 0;iqr = -2*Tem*Ls./(3*p*Lm*Fs);Ir(i) = sqrt(idr^2 + iqr^2);% stator currentsids = Fs/Ls;iqs = -iqr*Lm/Ls;Is(i) = sqrt(ids^2 + iqs^2);% Stato vlotagesuds = Rs*ids;uqs = Rs*iqs;Us(i) = sqrt(uds^2 + uqs^2);% stator powersPs(i) = 1.5*(Rs*ids.^2 + rs*iqs.^2 + ws*Fs.*iqs);Qs(i) = 1.5*(uqs.*ids - uds.*iqs);Mod_ss =sqrt(Ps.^2 + Qs.^2);% wrwr = ws*ss;% rotor voltagesudr = Rr*idr - Lr*wr.*iqr - Lm*wr.*iqs;uqr = Rr*iqr + Lr*wr.*idr + Lm*wr.*ids;Vr(i) = sqrt(udr^2 + uqr^2);%rotor powersPr(i) = 1.5*(udr.*idr + uqr.*iqr);Qr(i) = 1.5*(uqr.*idr - udr.*iqr);Mod_Sr = sqrt(Pr.^2 + Qr.^2);% stator fluxFsd = Ls*ids + Lm*idr;Fsq = Ls*iqs + Lm*iqr;Fs(i)= sqrt(Fsd^2 + Fsq^2);% rotor fluxFrd = Lr*idr + Lm*ids;Frq = Lr*iqr + Lm*iqs;Fr(i)= sqrt(Frd^2 + Frq^2);% Mechanial powerPmec(i) = Tem*Wm/p;% efficiancyif Pmec(i) >= 0R(i) = Pmec(i) / (Ps(i) + Pr(i)); % Motor ModeelseR(i) = (Ps(i) + Pr(i))/Pmec(i); % Generator Modeendendfigure(1)subplot(3,3,1)hold onplot(wmm,Temm,'g',wmm,Temm,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Tem (Nm)','fontsize',14);gridxlim([700,2000]);subplot(3,3,2)title('Red: Qs = 0, Green: idr = 0','fontsize',12)hold onplot(wmm,Pr,'g',wmm,Ps+Pr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pt (W)','fontsize',14);gridxlim([700,2000]);subplot(3,3,3)hold onplot(wmm,Pr,'g',wmm,Pr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pr (W)','fontsize',14);xlim([700,2000]);subplot(3,3,3)hold onplot(wmm,Ps,'g',wmm,Ps,'*g','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ps & Pr (W)','fontsize',14);gridxlim([700,2000]);subplot(3,3,4)hold onplot(wmm,Is,'g',wmm,Is,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Is (A)','fontsize',14);gridxlim([700,2000]);subplot(3,3,5)hold onplot(wmm,Ir,'g',wmm,Ir,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ir (A)','fontsize',14);gridxlim([700,2000]);subplot(3,3,6)hold onplot(wmm,Vr,'g',wmm,Vr,'og',wmm,Us,'g',wmm,Us,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Vr & Vs (V)','fontsize',14);gridxlim([700,2000]);subplot(3,3,7)hold onplot(wmm,Qs,'g',wmm,Qs,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qs (VAR)','fontsize',14);gridxlim([700,2000]);subplot(3,3,8)hold onplot(wmm,Qr,'g',wmm,Qr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qr (VAR)','fontsize',14);gridxlim([700,2000]);subplot(3,3,9)hold onplot(wmm,R,'g',wmm,R,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Efficiency (pu)','fontsize',14);gridxlim([700,2000]);

author: ataradov
author_rank: Super Contributor
timestamp: March 03, 2018, 06:20:19 pm
content: Ps is declared as a scalar value earlier, and you try to use it as an array.Although Matlab does not seem to care if you do stuff like that.

author: ataradov
author_rank: Super Contributor
timestamp: March 03, 2018, 06:35:26 pm
content: yes, if you manually evaluate the right side, it evaluates to a two-value vector. And Ps is a single value.Code:In an assignment A(:) = B, the number of elements in A and B must be the same.Error in untitled (line 78)Ps(i)= 1.5*(Rs*ids.^2 + Rs*iqs.^2 + ws*Fs.*iqs);>> 1.5*(Rs*ids.^2 + Rs*iqs.^2 + ws*Fs.*iqs)ans =-78.6630748177035e+003 -78.6630748177035e+003

author: ahbushnell
author_rank: Frequent Contributor
timestamp: March 03, 2018, 09:47:47 pm
content: Quote from: abrarbaig on March 03, 2018, 06:07:16 pmI think you need period after the second iqs at the end of the equation.

author: abrarbaig
author_rank: Contributor
timestamp: March 04, 2018, 10:24:17 am
content: Hi. Thanks for everyone who has participated and gave your inputs. I have fixed the code. Now its working error free. Just need some fine tuning. It should be done soon.

author: fathi
author_rank: Newbie
timestamp: May 10, 2018, 05:50:59 pm
content: for me it's the samedid you find the solutionhow the programm will be??

author: mbless
author_rank: Regular Contributor
timestamp: May 10, 2018, 06:06:05 pm
content: Quote from: fathi on May 10, 2018, 05:50:59 pmWhat's the error, and what's your code?The above error was because OP was assigning a 1x2 matrix to a 1x1 matrix.

author: fathi
author_rank: Newbie
timestamp: May 10, 2018, 06:13:20 pm
content: This is my code% %clear all% difg parametrs -> Rotor parameters refered to the stator sidef = 50; % Stator frequency (Hz)Ps = 2e6; % rated stator power (W)n = 1500; % Ratede rotational speed (rev/min)Vs = 690; % Rated voltage stator (V)Is = 1760; % Rated stator current (A)Tem = 12732; % Rated torque (N.m)p = 2; % Pole pairu =1/3; % Stator/rotor turns ratioVr = 2070; % Rated rotor voltage (non-reached)(V)smax = 1/3; % Maximum slipVr_stator = (Vr*smax)*u; % Rated rotor voltage referred to stator (V)Rs = 2.6e-3; % Stator resistance (ohm)Lsi = 0.087e-3; % Leakage inductance (stator & rotor) (H)Lm = 2.5e-3; % magnetizing inductance (H)Rr = 2.9e-3; % Rotor resistance referred to stator (ohm)Ls = Lm + Lsi; % Stator induction (H)Lr = Lm + Lsi; % Rotor induction (H)Vbus = Vr_stator*sqrt(2); % DC de bus voltage referred to stator (V)sigma = 1-Lm^2/(Ls*Lr); %Vs=690*sqrt(2/3);ws=f*2*pi;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Max and minimum speeds de 2.4MWwt_nom=18;wt_min=9;%Gearbox ratioN=100;% Torque and speed arrays (inputs)wt=[0.9425,0.9425,0.9425,0.9425,1.0476,1.1429,1.2381,1.3333,1.4286,...1.5238,1.6190,1.7143,1.8095,1.8850,1.8850,1.8850,1.8850,1.8850,...1.8850,1.8850,1.8850];Torque=-1e6*[0.0501,0.1164,0.1925,0.2696,0.3262,0.3883,0.4557,0.5285,...0.6067,06902,0.7792,0.8736,0,9733,1.0894,1.2474,1.2745,1.2745,...1.2745,1.2745,1.2745,1.2745];Temm=Torque/N; % Convert to machine sidewmm=wt*(60/2/pi)*N; % Convert to machine side (in rpm)sss=(1500-wmm)/1500; % slip%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Qs=0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Ref_Qs_ =0*ones(size(sss));i=0;for ss=sss,i=i+1;Tem= Temm(i);Ref_Qs=Ref_Qs_(i);Wm=ws*(1-ss);s(i)=ss;A=ws*ws*Lm*Lm;B=4*Rs*Tem*ws/3-((Vs)^2);C=4*Rs*Rs/(9*Lm*Lm)*((Ref_Qs^2)/(ws^2)+(Tem.^2)/(p^2));X1=(-B+sqrt(B.^2-4*A.*C))./(2*A);X2=(-B-sqrt(B.^2-4*A.*C))./(2*A);Fs=Lm*sqrt(X1);Fs_(i)=Fs;%Stator currentsids =2*Ref_Qs./(3*ws*Fs);iqs=2*Tem./(3*p*Fs);Is(i)=sqrt(ids^2+ids^2);% Stator voltagesuds=Rs*ids;uqs=Rs*iqs+ws*Fs;Us(i)=sqrt(uds^2+uqs^2);% Stator powerPs(i)=1.5*(Rs*ids.^2+Rs*iqs.^2+ws*Fs.*iqs);Qs(i)=Ref_Qs;Mod_Ss=sqrt(Ps.^2+Qs.^2);% Rotor currentsidr=Ls*ids/Lm+Fs/Lm;iqr=Ls*iqs/Lm;Ir(i)=sqrt(idr^2+iqr^2);%wrwr=ws*ss;% Rotor voltage;udr=Rr*idr-Lr*wr.*iqr-Lm*wr.*iqs;uqr=Rr*iqr+Lr*wr.*idr+Lm*wr.*ids;Vr(i)=sqrt(udr^2+uqr^2);% Rotor powerPr(i)=1.5*(udr.* idr+uqr.*iqr);Qr(i)=1.5*(uqr.*idr-udr.*iqr);Mod_Sr=sqrt(Pr.^2+Qr.^2);% Stator fluxFsd=Ls*ids+Lm*idr;Fsq=Ls*iqs+Lm*iqr;Fs_(i)=sqrt(Fsd*Fsd+Fsq*Fsq);% Rotor fluxFrd=Lr*idr+Lm*ids;Frq=Lr*iqr+Lm*iqs;Fr(i)=sqrt(Frd*Frd+Frq*Frq);% Mecanical powerPmec(i)=Tem*Wm/p;% Efficiencyif Pmec(i)>=0R(i)=Pmec(i)/(Ps(i)+Pr(i)); % Motor ModeelseR(i)=(Ps(i)+Pr(i))/Pmec(i); % Generator Modeendendfigure(1)subplot(3,3,1)hold onplot(wmm,Temm,'r',wmm,Temm,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Tem (Nm)','fontsize',14);xlim([700 ,2000]);subplot(3,3,2)hold onplot(wmm,Ps+Pr,'r',wmm,Ps+Pr,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pt (Nm)','fontsize',14);xlim([700 ,2000]);subplot(3,3,3)hold onplot(wmm,Pr,'r',wmm,Pr,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pr (W)','fontsize',14);xlim([700 ,2000]);subplot(3,3,3)hold onplot(wmm,Ps,'r',wmm,Pr,'or','linewidth',1.5);xlim([700 ,2000]);subplot(3,3,4)hold onplot(wmm,Is,'r',wmm,Ir,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Is (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,5)hold onplot(wmm,Ir,'r',wmm,Ir,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ir (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,6)hold onplot(wmm,Vr,'r',wmm,Vr,'or',wmm,Us,'r',wmm,Us,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Vr (V)','fontsize',14);xlim([700 ,2000]);subplot(3,3,7)hold onplot(wmm,Qs,'r',wmm,Qs,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qs (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,8)hold onplot(wmm,Qr,'r',wmm,R,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qr (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,9)hold onplot(wmm,R,'r',wmm,R,'or','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Efficiency (pu)','fontsize',14);xlim([700 ,2000]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% idr =0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%i=0;for ss=sss,i=i+1;Tem= Temm(i);Ref_Qs=Ref_Qs_(i);Wm=ws*(1-ss);s(i)=ss;A=ws*ws*Lm*Lm + (Rs*Lm/Ls)^2;B=4*Rs*Tem*ws/3/p-((Vs)^2);C=4*Rs*Rs*Tem*Tem/(9*p*p*Lm*Lm);X1=(-B+sqrt(B.^2-4*A.*C))./(2*A);X2=(-B-sqrt(B.^2-4*A.*C))./(2*A);ims=sqrt(X1);ims_(i)=ims;Fs=ims*Lm;% Rotor currentsidr=0;iqr=2*Tem*Ls./(3*p*Lm*Fs);Ir(i)=sqrt(idr^2+iqr^2);%Stator currentsids=Fs/Ls;iqs=-iqr*Lm/Ls;Is(i)=sqrt(ids^2+ids^2);% Stator voltagesuds=Rs*ids;uqs=Rs*iqs+ws*Fs;Us(i)=sqrt(uds^2+uqs^2);% Stator powersPs(i)=1.5*(Rs*ids.^2+Rs*iqs.^2+ws*Fs.iqs);Qs(i)=1.5*(uqs.*ids-uds.*iqs);Mod_Ss=sqrt(Ps.^2+Qs.^2);%wrwr=ws*ss;% Rotor currentsidr=0;iqr=2*Tem*Ls./(3*p*Lm*Fs);Ir(i)=sqrt(idr^2+iqr^2);% Rotor voltage;udr=Rr*idr-Lr*wr.*iqr-Lm*wr.*iqs;uqr=Rr*iqr+Lr*wr.*idr+Lm*wr.*ids;Vr(i)=sqrt(udr^2+uqr^2);% Rotor powersPr(i)=1.5*(udr.*idr+uqr.*iqr);Qr(i)=1.5*(uqr.*idr-udr.*iqr);Mod_Sr=sqrt(Pr.^2+Qr.^2);% Stator fluxFsd=Ls*ids+Lm*idr;Fsq=Ls*iqs+Lm*iqr;Fs_(i)=sqrt(Fsd*Fsd+Fsq*Fsq);% Rotor fluxFrd=Lr*idr+Lm*ids;Frq=Lr*iqr+Lm*iqs;Fr(i)=sqrt(Frd*Frd+Frq*Frq);% Mecanical powerPmec(i)=Tem*Wm/p;% Efficencyif Pmec(i)>=0R(i)=Pmec(i)/(Ps(i)+pr(i)); % Motor ModeelseR(i)=(Ps(i)+Pr(i))/Pmec(i); % Generator Modeendendfigure(1)subplot(3,3,1)hold onplot(wmm,Temm,'g',wmm,Temm,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Tem (Nm)','fontsize',14);xlim([700 ,2000]);subplot(3,3,2)title('Red: Qs=0, Gree: idr=0','fontsize',12)hold onplot(wmm,Ps+Pr,'g',wmm,Ps+Pr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pt (Nm)','fontsize',14);xlim([700 ,2000]);subplot(3,3,3)hold onplot(wmm,Pr,'g',wmm,Pr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pr (W)','fontsize',14);xlim([700 ,2000]);subplot(3,3,3)hold onplot(wmm,Ps,'g',wmm,Pr,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Pr & Ps (W)','fontsize',14);xlim([700 ,2000]);subplot(3,3,4)hold onplot(wmm,Is,'g',wmm,Ir,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Is (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,5)hold onplot(wmm,Ir,'g',wmm,Ir,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Ir (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,6)hold onplot(wmm,Vr,'g',wmm,Vr,'or',wmm,Us,'r',wmm,Us,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Vr (V)','fontsize',14);xlim([700 ,2000]);subplot(3,3,7)hold onplot(wmm,Qs,'g',wmm,Qs,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qs (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,8)hold onplot(wmm,Qr,'g',wmm,R,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Qr (A)','fontsize',14);xlim([700 ,2000]);subplot(3,3,9)hold onplot(wmm,R,'g',wmm,R,'og','linewidth',1.5);xlabel('n (rpm)','fontsize',14);ylabel('Efficiency (pu)','fontsize',14);xlim([700 ,2000]);don't know how th correct itI

author: mbless
author_rank: Regular Contributor
timestamp: May 10, 2018, 06:44:52 pm
content: Code:Error using plotVectors must be the same length.Error in Untitled (line 136)plot(wmm,Temm,'r',wmm,Temm,'or','linewidth',1.5);That's a very detailed error message, so I won't spoon feed you the answer.Go through it systematically: What are the lengths of the 'wmm' and 'Temm' variables?