Functions and Global Variables

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 件のコメント

Yash Shil Balgobin
Yash Shil Balgobin 2021 年 4 月 3 日
編集済み: Yash Shil Balgobin 2021 年 4 月 3 日
This is the question. How can i do from the above codes ? I need to get the answers from the command window, not by running the program. Please note that i have already declared the variable COUNTER and initialized it to 0.
dpb
dpb 2021 年 4 月 3 日
The assignment doesn't ask for the user to input data within either task function...
Yash Shil Balgobin
Yash Shil Balgobin 2021 年 4 月 3 日
@dpb So, how am i supposed to get the data from ?
dpb
dpb 2021 年 4 月 3 日
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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeArduino Hardware についてさらに検索

製品

リリース

R2020b

質問済み:

2021 年 4 月 3 日

コメント済み:

dpb
2021 年 4 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by