Results 1 to 2 of 2

Math Help - Matlab While Loop Help

  1. #1
    Newbie
    Joined
    Mar 2009
    Posts
    1

    Matlab While Loop Help

    Hi,

    I am trying to write a matlab program that uses a while loop to prompt the user for the name of an excel file if the user entered the name incorrectly. The loop will continue to run until the name is entered correctly.

    What I have so far is...

    x = input('Please enter the name of the excel file: ','s');

    while ___________

    x = input('Please enter the correct name of the the file: ','s');

    end

    ---------------
    Where I have the blank after the while portion is where i do not know what to put. I have tried "while x ~= 'LabData'" and this doesn't work. I've also tried "while strcmp(x, "LabData") and this runs when the name is correct, which is the opposite of what i want.

    P.S. "LabData" is the name of the excel file i want the user to enter.

    Thanks for any help anyone can offer.
    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 J_Nguyen View Post
    Hi,

    I am trying to write a matlab program that uses a while loop to prompt the user for the name of an excel file if the user entered the name incorrectly. The loop will continue to run until the name is entered correctly.

    What I have so far is...

    x = input('Please enter the name of the excel file: ','s');

    while ___________

    x = input('Please enter the correct name of the the file: ','s');

    end

    ---------------
    Where I have the blank after the while portion is where i do not know what to put. I have tried "while x ~= 'LabData'" and this doesn't work. I've also tried "while strcmp(x, "LabData") and this runs when the name is correct, which is the opposite of what i want.

    P.S. "LabData" is the name of the excel file i want the user to enter.

    Thanks for any help anyone can offer.
    while (strcmp(x, 'LabData')==0)

    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, 02:07 AM
  2. Matlab while loop, Please help!
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 23rd 2010, 01:14 AM
  3. help with MATLAB questdlg loop
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 7th 2010, 09:23 AM
  4. Creating a loop in Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 03:06 AM
  5. Matlab loop help
    Posted in the Math Software Forum
    Replies: 2
    Last Post: July 20th 2008, 10:47 AM

Search Tags


/mathhelpforum @mathhelpforum