Results 1 to 2 of 2

Math Help - Matlab while loop, Please help!

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    1

    Exclamation Matlab while loop, Please help!

    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
    
    
    functionanswer = Evaluation(info);
    
    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!
    Last edited by CaptainBlack; April 23rd 2010 at 02:14 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by akhanijow View Post
    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
    
    
    functionanswer = Evaluation(info);
    
    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!

    Why are you not using the same general syntax you used for info(1) to info(3)?

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab question! Help! Infinite loop.
    Posted in the Math Software Forum
    Replies: 3
    Last Post: June 30th 2010, 03:07 AM
  2. help with MATLAB questdlg loop
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 7th 2010, 10:23 AM
  3. Creating a loop in Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 04:06 AM
  4. Matlab While Loop Help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 8th 2009, 08:50 PM
  5. Matlab loop help
    Posted in the Math Software Forum
    Replies: 2
    Last Post: July 20th 2008, 11:47 AM

Search Tags


/mathhelpforum @mathhelpforum