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

1 visualización (últimos 30 días)
Aydan Peak
Aydan Peak el 31 de Oct. de 2019
Respondida: Ajay Kumar el 1 de Nov. de 2019
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!

Respuestas (1)

Ajay Kumar
Ajay Kumar el 1 de Nov. de 2019
"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);

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by