Results 1 to 3 of 3

Math Help - [SOLVED] basic matlab problem giving me errors

  1. #1
    Senior Member
    Joined
    Jan 2009
    Posts
    296

    [SOLVED] basic matlab problem giving me errors

    nevermind, got it


    Mr F edit: Original question restored.
    To the OP: Do not delete questions.


    Quote Originally Posted by zhupolongjoe
    We need a function that takes a name like 'first middle last' OR 'first last' and returns only the initials. What I have below keeps giving errors. Any ideas?

    function
    allInits=inits(name)
    spaceplaces=findstr(name,
    ' ');
    initfirst=name(1);
    firstspaceplace=spaceplaces(1);
    secondspaceplace=spaceplaces(2);
    if spacesplaces<2;
    allInits=[
    'initfirst''firstspaceplace+1']
    else
    allInits=['initfirst''firstspaceplace+1''secondspaceplace+1'];
    end
    Last edited by mr fantastic; February 14th 2009 at 06:53 PM. Reason: See my edit note above
    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 zhupolongjoe View Post
    We need a function that takes a name like 'first middle last' OR 'first last' and returns only the initials. What I have below keeps giving errors. Any ideas?

    function allInits=inits(name)
    spaceplaces=findstr(name,' ');
    initfirst=name(1);
    firstspaceplace=spaceplaces(1);
    secondspaceplace=spaceplaces(2);
    if spacesplaces<2;
    allInits=['initfirst''firstspaceplace+1']
    else
    allInits=['initfirst''firstspaceplace+1''secondspaceplace+1'];
    end
    In the editor set a breakpoint on the first line after the function statement.

    Then call the function with a suitable string and then single step through the code (you will be in debug mode) examining what each line does.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member
    Joined
    Jan 2009
    Posts
    296
    I appreciate you trying to help, but in actuality, I haven't a clue what any of that means....I have never done any programming (and honestly don't intend to after this required course) and this is only our second assignment on Matlab.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. MATLAB - Need some help with errors
    Posted in the Math Software Forum
    Replies: 1
    Last Post: March 28th 2010, 09:17 PM
  2. Basic Matlab help. Can't seem to grasp basic concept
    Posted in the Math Software Forum
    Replies: 5
    Last Post: February 28th 2010, 09:12 PM
  3. logs problem giving trouble
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: December 21st 2009, 01:17 PM
  4. Replies: 1
    Last Post: February 12th 2009, 03:19 PM

Search Tags


/mathhelpforum @mathhelpforum