How do I stop a code from continuing ifelse statements?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm creating a script that converts phasor to complex numbers and then back again once I'm done converting. However if I only have one phasor to convert the script runs until the very end. How do I end the whole script if it satisfies what the user wants to do with it. For instance, if a==1 I want it to do the conversion then finish.
Mag1=input('What is the magnitude in the frequency domain? ');
Angle1=input('What is the angle in the frequency domain? ');
x=Mag1*cosd(Angle1)+Mag1*sind(Angle1)*1i
mag=abs(x);
rad=angle(x);
%z=complex(x)
disp('Enter 1 for yes, 0 for no')
a=input('Are you done converting from phasor to complex?' );
if a==1
mag=abs(x)
rad=angle(x);
deg=rad*180/pi
elseif a==0
Mag2=input('What is the second magnitude?' )
Angle2=input('What is the second angle? ' )
x1=Mag2*cosd(Angle2)+Mag2*sind(Angle2)*1i
mag=abs(x1);
rad=angle(x1);
%z=complex(x)
end
b=input('Are you done coverting now? ');
if b==1
c=input('Would you like to add the two complex numbers together? ' );
if c==1
z=x+x1
elseif c==0
z=x
Thank you for any suggestions you may have.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!