How do I create a vector from two user-input variables?

조회 수: 1 (최근 30일)
Aydan Peak
Aydan Peak 2019년 10월 31일
답변: Ajay Kumar 2019년 11월 1일
The problem is telling me to do this:
Determine the total profit for the number of years requested by the user.
The total profit vector should be calculated for the number of years requested, where each column is a year.
So say, the Profit is 1,000,000 for 5 Years, how would I put Profit and Years in a vector?
I tried (Profit:Years), but I guess you aren't able to do that.
Any help would be appreciated.
Thank you!

답변 (1개)

Ajay Kumar
Ajay Kumar 2019년 11월 1일
"for the number of years requested by the user."
you mean, you want the user to enter the number of years using input ?
If yes,
prompt = 'Enter number of years? ';
x = input(prompt);
y = x*200000;
fprintf('The profit is %d.\n', y);

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by