If part of While loop not executing any functions

1 view (last 30 days)
Harrison Forlines
Harrison Forlines on 28 Nov 2021
Edited: VBBV on 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???

Answers (1)

VBBV
VBBV on 28 Nov 2021
Edited: VBBV on 28 Nov 2021
while PF == isempty(PF)
if all(Pact == isempty(Pact)) && and(Pre == isempty(Pre))
break
else
Papp = sqrt((Pact.^2)+(Pre.^2));
PF = Pact./Papp;
end % use an if-else combination
end
Pin = (VR).*(IR).*sqrt(3).*(PF);
Use an if-else combination. Also change the if condition which seems to be true and therefore executes break and exits the while loop

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!