You are on page 1of 16

# >> b=zeros(4,1)

b=

>> b=zeros(1,4)

b=

0 0 0 0

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>
>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>> home

>> b=zeros(4,1)

b=

0
>> b=zeros(4,1)

b=

>> b(1)=-5

b=

-5

>> b=zeros(1,4)

b=

0 0 0 0

>> b(1)=-5
b=

-5 0 0 0

>> b(2)=9

b=

-5 9 0 0

>> A=zeros(2,3)

A=

0 0 0

0 0 0

>> A=(1,1)=5

A=(1,1)=5

>> A(1,1)=5

A=
5 0 0

0 0 0

>> b=[2357];

>> size(b)

ans =

1 1

## >> b=[2 3 5 7];

>> size(b)

ans =

1 4

>> length(b)

ans =

>> n=length(b);

>> n
n=

>> A(1,1)=5

A=

5 0 0

0 0 0

>> size(A)

ans =

2 3

>> [m n]=size(A);

>> m

m=

>> n
n=

X=

1 5

1 5

1 5

Y=

2 2

3 3

4 4

>> B=[1 5]

B=

1 5
>> X=[B;B;B]

X=

1 5

1 5

1 5

>> Y=[2 2]

Y=

2 2

>> Y=[Y;Y+1;Y+2]

Y=

2 2

3 3

4 4

Y=
2

>> Y=[Y,Y]

Y=

2 2

3 3

4 4

Z=

4 3

2 1

6 7

>> plot(x,y,z)

## Did you mean:

>> surf(X,Y,Z)
>> F=@(x,y)x+2*y+2;

>> Z=F(X,Y)

Z=

7 11

9 13

11 15

>> surf(X,Y,Z)

## >> Z=[-2 2;-2 3]

Z=

-2 2

-2 3

>> X=-2:2;

>> X=-2:2

X=

-2 -1 0 1 2

>> X=[X;X;X;X;X;X]
X=

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

>> Y=-2:3

Y=

-2 -1 0 1 2 3

>> Y=Y'

Y=

-2

-1

3
>> Y[Y,Y,Y,Y,Y]

Y[Y,Y,Y,Y,Y]

## Error: Unbalanced or unexpected parenthesis or bracket.

>> Y=[Y,Y,Y,Y,Y]

Y=

-2 -2 -2 -2 -2

-1 -1 -1 -1 -1

0 0 0 0 0

1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

>> X

X=

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2

-2 -1 0 1 2
>> f=@(X,Y)X^2-2*Y+1;

>> Z=f(X,Y)

Error using ^

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

Error in @(X,Y)X^2-2*Y+1

>> f=@(X,Y)X.^2-2*Y+1;

>> Z=f(X,Y)

Z=

9 6 5 6 9

7 4 3 4 7

5 2 1 2 5

3 0 -1 0 3

1 -2 -3 -2 1

-1 -4 -5 -4 -1

>> surf(X,Y,Z)

>> z=meshgrid(x,y)

## Undefined function or variable 'x'.

Did you mean:

>> z=meshgrid(x,y);

## Did you mean:

>> z=meshgrid(X,Y);

>> z=f(X,Y)

z=

9 6 5 6 9

7 4 3 4 7

5 2 1 2 5

3 0 -1 0 3

1 -2 -3 -2 1

-1 -4 -5 -4 -1

>> Z=meshgrid(X,Y);

>> z=f(X,Y)

z=

9 6 5 6 9

7 4 3 4 7

5 2 1 2 5

3 0 -1 0 3
1 -2 -3 -2 1

-1 -4 -5 -4 -1

Z=

-2 2

-2 3

## >> F=@(x,y)6e.^-3x.^2x-y.^2+1/2*x +y;

F=@(x,y)6e.^-3x.^2x-y.^2+1/2*x +y;

## >> F=@(x,y)6eexp.^-3x.^2x-y.^2+1/2*x +y;

F=@(x,y)6eexp.^-3x.^2x-y.^2+1/2*x +y;

## >> F=@(x,y)6exp.^-3x.^2x-y.^2+1/2*x +y;

F=@(x,y)6exp.^-3x.^2x-y.^2+1/2*x +y;

>>