17/5/20 4:00 PM MATLAB Command Window 1 of 4: Error: Unbalanced or Unexpected Parenthesis or Bracket

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

17/5/20 4:00 PM MATLAB Command Window 1 of 4

> f@(x) cos(x)-x


f@(x) cos(x)-x
|
Error: Unbalanced or unexpected parenthesis or bracket.

> f=@(x) cos(x)-x

f=

@(x)cos(x)-x

>> fzero(f,0)

ans =

0.7391

>> f=@(x,y) cos(x)-x-2*y

f=

@(x,y)cos(x)-x-2*y

>> fzero(f,00
fzero(f,00
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> fzero(f,0)
Error using fzero (line 289)
FZERO cannot continue because user supplied function_handle ==> @(x,y)cos(x)-x-2*y failed with
the error below.

Not enough input arguments.

>> fzero(f,0,2)
Error using fzero (line 289)
FZERO cannot continue because user supplied function_handle ==> @(x,y)cos(x)-x-2*y failed with
the error below.

Not enough input arguments.

>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
17/5/20 4:00 PM MATLAB Command Window 2 of 4

>>
>>
>>
>>
>>
>>
>>
>>
>> f=@(x) cos(x)-29*x

f=

@(x)cos(x)-29*x

>> fzero(f,0)

ans =

0.0345

>> ezplot(f,[0,1])
>> grid
>> printf
Undefined function or variable 'printf'.

>> ezplot(@(x,y) x^2+y^2=1,[1,5])


ezplot(@(x,y) x^2+y^2=1,[1,5])
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.

>> ezplot(@(x) x^2+2*x+1,[1,10])


Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up
its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 485
In ezplot at 145
>> ezplot(@(x) x.^2,[1,10])
>> grid
>> ezplot(@(x) x^3,[1,10])
Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up
its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 485
In ezplot at 145
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
17/5/20 4:00 PM MATLAB Command Window 3 of 4

>>
>> ezplot(@(x) x^4,[0,100])
Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up
its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 485
In ezplot at 145
>> ezplot(@(x) x^4,[-100,100])
Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up
its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 485
In ezplot at 145
>>
>>
>>
>> x=1:1:10

x=

1 2 3 4 5 6 7 8 9 10

>> y=1:2:10

y=

1 3 5 7 9

>> plot(x,y)
Error using plot
Vectors must be the same lengths.

>> y=x^2
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

>> syms x
>> x=1:0.5:10

x=

Columns 1 through 9

1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000

Columns 10 through 18

5.5000 6.0000 6.5000 7.0000 7.5000 8.0000 8.5000 9.0000 9.5000

Column 19

10.0000

>> y=x^3
Error using ^
17/5/20 4:00 PM MATLAB Command Window 4 of 4

Inputs must be a scalar and a square matrix.


To compute elementwise POWER, use POWER (.^) instead.

>> y=x.^3

y=

1.0e+03 *

Columns 1 through 9

0.0010 0.0034 0.0080 0.0156 0.0270 0.0429 0.0640 0.0911 0.1250

Columns 10 through 18

0.1664 0.2160 0.2746 0.3430 0.4219 0.5120 0.6141 0.7290 0.8574

Column 19

1.0000

>> plot(x,y)
>> plot(x,y0
plot(x,y0
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> plot(x,y)
>>
>> fprintf
Error using fprintf
Not enough input arguments.

>>

You might also like