Results 1 to 2 of 2

Math Help - MATLAB - Need some help with errors

  1. #1
    Junior Member
    Joined
    Dec 2008
    From
    London
    Posts
    45

    MATLAB - Need some help with errors

    I got this M-File and I need to look for the errors (theres 4 of them) for the file to function properly

    Code:
    function [c,d]=errors(x)
    
    %This function file generates a matrix d of which the elements
    %are the elements of x minus 1. At the same time it generates a
    %value c indicating how often the function file has gone through
    %the second for loop.
    
    [p,q]=size(x)
    for a=1:q
       for b=1:p
       d(a,b)=x(a,b)-1;
       c=c+1;
    end
    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 Kevlar View Post
    I got this M-File and I need to look for the errors (theres 4 of them) for the file to function properly

    Code:
    function [c,d]=errors(x)
    
    %This function file generates a matrix d of which the elements
    %are the elements of x minus 1. At the same time it generates a
    %value c indicating how often the function file has gone through
    %the second for loop.
    
    [p,q]=size(x)
    for a=1:q
       for b=1:p
       d(a,b)=x(a,b)-1;
       c=c+1;
    end
    Have you checked the red and/or amber marks in the right margin of the Matlab editor window?

    Have you tried running this on a non-square random matrix?

    How about in the debugger?

    I am closing this thread, since any further assistance with this will defeat the purpose of the exercise, which is for you to debug this code.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Errors all the time?
    Posted in the LaTeX Help Forum
    Replies: 2
    Last Post: April 16th 2011, 04:36 AM
  2. Algebra of errors
    Posted in the Algebra Forum
    Replies: 3
    Last Post: October 21st 2010, 04:02 PM
  3. [SOLVED] basic matlab problem giving me errors
    Posted in the Math Software Forum
    Replies: 2
    Last Post: February 14th 2009, 02:53 PM
  4. Fixing log errors.
    Posted in the Algebra Forum
    Replies: 1
    Last Post: May 2nd 2007, 06:29 PM

Search Tags


/mathhelpforum @mathhelpforum