//to calculate generator terminal voltage,excitation emf,power angle clc; Xd=1.48; Xq=1.24; Xe=.1; Xdt=Xd+Xe; Xqt=Xq+Xe; MVA=1; Vb=1; pf=.9; phi=acosd(pf); //(Vt*cosd(phi))^2+(Vt*sind(phi)+Ia*Xe)^2=Vb^2; //after solving //Vt^2-.0870*Vt-.99=0; function [x]=quad(a,b,c) d=sqrt(b^2-4*a*c); x1=(-b+d)/(2*a); x2=(-b-d)/(2*a); if(x1