Cody

# Problem 1261. Find the definite integral of various linear functions

Solution 2952361

Submitted on 16 Sep 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
x = '3*x'; lower=0; upper=3; y_correct = 0; assert(isequal(myintegrate(x,lower,upper),y_correct))

Error using myintegrate>@(x)e([f,'(',num2str(x),')']) (line 3) Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t); Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval); Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct); Error in myintegrate (line 3) y = integral(@(x) e([f,'(',num2str(x),')']), l,u); Error in Test1 (line 4) assert(isequal(myintegrate(x,lower,upper),y_correct))

2   Fail
x = '6*x'; lower=2; upper=6; y_correct = 0; assert(isequal(myintegrate(x,lower,upper),y_correct))

Error using myintegrate>@(x)e([f,'(',num2str(x),')']) (line 3) Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t); Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval); Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct); Error in myintegrate (line 3) y = integral(@(x) e([f,'(',num2str(x),')']), l,u); Error in Test2 (line 4) assert(isequal(myintegrate(x,lower,upper),y_correct))

3   Fail
x = '2*x'; lower=0; upper=2; y_correct = 0; assert(isequal(myintegrate(x,lower,upper),y_correct))

Error using myintegrate>@(x)e([f,'(',num2str(x),')']) (line 3) Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t); Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen); Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval); Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct); Error in myintegrate (line 3) y = integral(@(x) e([f,'(',num2str(x),')']), l,u); Error in Test3 (line 4) assert(isequal(myintegrate(x,lower,upper),y_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!