Problem in matlab with too many outputs

Posted by Ben Fossen on Stack Overflow See other posts from Stack Overflow or by Ben Fossen
Published on 2010-04-02T06:24:59Z Indexed on 2010/04/02 6:33 UTC
Read the original article Hit count: 397

Filed under:

I am writing a Matlab program for simpson's rule I keep getting an error about to many outputs when the program gets to left_simpson = Simpson(a,c,(e1)/2,level, level_max); What is wrong with settinf left_simpson to Simpson(a,c,(e1)/2,level, level_max);?

function Simpson(a,b,e1,level, level_max)


level = level + 1;

h = b - a;

c = (a+b)/2;

one_simpson = h*(f(a) + 4*f(c) + f(b))/6;

d = (a+c)/2;

e = (c+b)/2;

two_simpson = h*(f(a) + 4*f(d) + 2*f(c) + 4*f(e))/2;

if level >= level_max

    disp('h')

    simpson_result = two_simpson;

    disp('maximum levels reached')

    disp(simpson_result);

    if abs(two_simpson - one_simpson) < 15*e1

        simpson_result = two_simpson + (two_simpson - one_simpson)/15;

    else 
        left_simpson = Simpson(a,c,(e1)/2,level, level_max);

        right_simpson = Simpson(c,b,(e1)/2,level, level_max);

        simpson_result = left_simpson + right_simpson;

    end

end

© Stack Overflow or respective owner

Related posts about matlab