• MATLAB

## Main Question or Discussion Point

Hi everyone,

I am writing a matlab program and am having some issues. Here is the code I have written so far:

Code:
clear all
clc

info(1) = input('What is the MARR (%)? ');
info(2) = input('What is the lifetime of the project? ');
info(3) = input('What is the initial investment (\$)? ');

m=0;
while m < info(2)
m = m+1;
info(4) = m;
info(5) = input('What is the maintenance cost for year',num2str(m),' ? ');
end

disp('The Present Value of the project is');
disp(functionanswer(1));

For info(5), I am trying to make it say "what is the maintenance cost for year __?"
I have tried using num2str, and may other things but cant seem to get it! Any help would be great! Thanks!

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
D H
Staff Emeritus
Have you tried reading the documentation on the input function?

Hey,
Yes I did, I still cant seem to figure it out...I tried using the %d function and num2str, but its failed to work. I also tried using 's', but that is for a string, and I am just trying to have the input show up as:

"What is the maintenance cost for year __?"

Any idea, thanks so much!

Also, http://www.uni-koeln.de/rrzk/software/mathematik/matlab_help/techdoc/ref/input.html" is what I read on the input function:

Last edited by a moderator:
D H
Staff Emeritus