You are on page 1of 3

4/25/18 11:06 AM MATLAB Command Window 1 of 3

>> y = @ (x) x^2-1

y =

function_handle with value:

@(x)x^2-1

>> trap(y,0,5,5)
Undefined function or variable 'trap'.

Did you mean:


>> trapz(y,0,5,5)
Error using trapz
Too many input arguments.

>> trap(y,0,5,5)
Undefined function or variable 'trap'.

Did you mean:


>> trap (y,0,5,5)
Undefined function or variable 'trap'.

Did you mean:


>> trap
Error using trap (line 12)
at least 3 input arguments required

>> trap (y,0,5,5)

ans =

37.5000

>> trap
Error using trap (line 12)
at least 3 input arguments required

>> trap (y,0,5,5)

ans =

37.5000

>> trap (y,0,5,100)

ans =

36.6687

>> romberg
Error: File: romberg.m Line: 16 Column: 36
Unexpected MATLAB expression.
4/25/18 11:06 AM MATLAB Command Window 2 of 3

>> romberg
Error: File: romberg.m Line: 16 Column: 36
Unexpected MATLAB expression.

>> romberg(y,0.5,0.00001,5)
Error: File: romberg.m Line: 16 Column: 36
Unexpected MATLAB expression.

>> romberg
Error: File: romberg.m Line: 16 Column: 36
Unexpected MATLAB expression.

>> romberg
Error: File: romberg.m Line: 16 Column: 36
Unexpected MATLAB expression.

>> romberg
Error using romberg (line 15)
at least 3 input arguments required

>> romberg
Error using romberg (line 15)
at least 3 input arguments required

>> romberg
Error using romberg (line 15)
at least 3 input arguments required

>> romberg
Error using romberg (line 15)
at least 3 input arguments required

>> romberg(y,0,5,0.00001,5)

ans =

36.6667

>> trap
Error using trap (line 12)
at least 3 input arguments required

>> y= (@) 1-e^(-x)


y= (@) 1-e^(-x)

Error: Unbalanced or unexpected parenthesis or bracket.

>> @(x)1-exp(-x)

ans =

function_handle with value:

@(x)1-exp(-x)
4/25/18 11:06 AM MATLAB Command Window 3 of 3

>> trap (y,0,4,5)

ans =

17.7600

>> y = @(x)1-exp(-x)

y =

function_handle with value:

@(x)1-exp(-x)

>> trap (y,0,4,5)

ans =

2.9665

>> format long


>> trap (y,0,4,5)

ans =

2.966509232940782

>> trap (y,0,4,5)

ans =

2.966509232940782

>> trap (y,0,4,5)

ans =

2.966509232940782

>> trap (y,0,5,10000)

ans =

4.006737926306090

>>

You might also like