Functions and Global Variables
Afficher commentaires plus anciens
This is my code. (Edited)
function B = PBTask4P2b_f(COUNTER)
B = input('TRUCK B: ');
while COUNTER < 1000
B = B + COUNTER;
if COUNTER > 1000
COUNTER = 0;
fprintf('Counter has been reset to 0.\n')
else
fprintf('COUNTER = %f.\n',B);
end
end
end
4 commentaires
Yash Shil Balgobin
le 3 Avr 2021
Modifié(e) : Yash Shil Balgobin
le 3 Avr 2021
dpb
le 3 Avr 2021
The assignment doesn't ask for the user to input data within either task function...
Yash Shil Balgobin
le 3 Avr 2021
dpb
le 3 Avr 2021
The example usage of your functions in the problem statement shows it being passed as an argument to the two functions, doesn't it?
Your way, there's no need for an argument variable.
Réponses (0)
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
