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

MATLAB Command Window Page 1

>> x = [5 7 -2 4 -6]

x =

5 7 -2 4 -6

>> y = [2,1,3,7]

y =

2 1 3 7

>> z = [0 1 2,3 4,5]

z =

0 1 2 3 4 5

>> w = [1 ;2; 3]

w =

1
2
3

>>
>> x = [5 7 -2 4 -6];
>> x (2)

ans =

>> x (end)

ans =

-6

>>
>> x = [5 7 -2 4 -6];
>> x (6)=8

x =

5 7 -2 4 -6 8

>> x(10)=7

x =
MATLAB Command Window Page 2

Columns 1 through 7

5 7 -2 4 -6 8 0

Columns 8 through 10

0 0 7

>>
>> x = [5 7 -2 4 -6];
>> w = [1 2 3 4];
>> z1=[x w]

z1 =

Columns 1 through 7

5 7 -2 4 -6 1 2

Columns 8 through 9

3 4

>> z2=[x(1) w x(3)]

z2 =

5 1 2 3 4 -2

>>
>> x = [5 7 -2 4 -6];
>> x (2:4)

ans =

7 -2 4

>>
>> x = [1 2 3 4 5 6 7];
>> x(4) = []

x =

1 2 3 5 6 7

>> x(2:5) = []

x =

1 7
MATLAB Command Window Page 3

>>
>> x = [5 7 -2 4 -6];
>> x (1:2:5)

ans =

5 -2 -6

>>
>> x = [5 7 -2 4 -6];
>> x ( [3 5 1] )

ans =

-2 -6 5

>>
>> v=[1 2 3]

v =

1 2 3

>> sin(v)

ans =

0.8415 0.9093 0.1411

>> log(v)

ans =

0 0.6931 1.0986

>>
>> x=1:10

x =

Columns 1 through 7

1 2 3 4 5 6 7

Columns 8 through 10

8 9 10

>> y=x.^2-2*x-3
MATLAB Command Window Page 4

y =

Columns 1 through 7

-4 -3 0 5 12 21 32

Columns 8 through 10

45 60 77

>> a=(1 2 3), b=(-2 3 5)


a=(1 2 3), b=(-2 3 5)

Error: Invalid expression. Check for


missing multiplication operator, missing
or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets
instead of parentheses.

>> a=(1 2 3)
a=(1 2 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.

>>

You might also like