Effacer les filtres
Effacer les filtres

If part of While loop not executing any functions

1 vue (au cours des 30 derniers jours)
Harrison Forlines
Harrison Forlines le 28 Nov 2021
VR = input('Input value of rated voltage of (VR) of 3-phase induction motor being tested: ');
IR = input('Input value of rated current (IR) of 3-phase induction motor being tested: ');
Pact = input('Input value of active/real power (Pact), or press enter if N/A: ');
Pre = input('Input value of reactive power (Pre), or press enter if N/A: ');
Papp = input('Input value of apparent power (Papp), or press enter if N/A: ');
PF = input('Input value of power factor (PF), or press enter if N/A: ');
*All of the above input values were imputted except for Papp & PF which were just left blank for calulation in the while loop
*Pact & Pre are 1-column arrays respectivly
while PF == isempty(PF)
if all(Pact ~= isempty(Pact)) && and(Pre ~= isempty(Pre))
break
end
Papp = sqrt((Pact.^2)+(Pre.^2));
PF = Pact./Papp;
end
Pin = (VR).*(IR).*sqrt(3).*(PF);
But when I execute the loop the values for Pin, Papp, & PF are still shown in the workspace as [ ] and are empty. I've tried all sorts of different combinations does anyone know how i can fix this???

Réponses (1)

Taylor
Taylor le 10 Jan 2024
You're never entering the loop. You will only ever enter that loop if PF = 0 because isempty(PF) will always yield 0 if a value is present. If no value is given for PF, isempty will yield 1, but the overall logical for entering the while loop will be 0.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by