one more matlab

edited February 2009 in Science & Tech
/////

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited February 2009
    well, do you ever assign a value to lengthwords (which is what is returned by your fuction)?
  • edited February 2009
    Ok:


    function
    lengthwords=wordLengths(line)
    spaces=findstr(' ', line);
    index=-1;
    while index~=spaces;
    index==index+1
    lengthwords=index(line);
    return
    end
    end

    I get error:
    ??? Index exceeds matrix dimensions.
    Error in ==> wordLengths at 6
    lengthwords=index(line);



  • shwaipshwaip bluffin' with my muffin Icrontian
    edited February 2009
    You need to spend time reviewing basic programming concepts. In the three threads you've posted, your code starts out almost completely incorrect, with mistakes that you should have picked up via error messages that matlab gives you.

    In this question, you clearly aren't understanding how:

    a) indexing works
    b) matlab indexing works.

    when you say:
    lengthwords=index(line);

    You're trying to use line (which is a string) to index into the variable index (which is a scalar).
  • edited February 2009
    Jeez..I can't wait till this class ends so I can delete Matlab from my computer forever and snap the disk in half....I ace 400 level, proof-based math courses, but this 100 level computer science course is the bane of my existence.
  • edited February 2009
    .............
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited February 2009
    explain to me how you're trying to solve this problem, in psuedocode ie:

    step 1: find the locations of the spaces, using findstr();
    .
    .
    .

    this doesn't have to be anything that will work at all in matlab, just to give me an idea of how to help you.

    After you've written the pseudocode, then see if your code matches up with it at all.
Sign In or Register to comment.