How do you divide 120 by x when x is (3,6] starting with x=0
Mostra commenti meno recenti
I am trying to do a while statement that divdes 120 by the numbers between (3,6] and only gives nonzero() answers, but so far my code only gives me the last value "20". Is there a way to fix the code so I get all three values, 30, 24, and 20?
x=0;
while (x>2) & (x<=5)
x=x+1;
Q2(x) = 120/x;
end
disp('Q2 =')
disp(nonzeros(Q2))
Risposta accettata
Più risposte (1)
David Hill
il 5 Mar 2022
Modificato: David Hill
il 5 Mar 2022
Q2=120./(4:6)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!