If part of While loop not executing any functions

1 view (last 30 days)
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)

Taylor
Taylor on 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.

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!