You are on page 1of 3

>> x=[3 1 7 5];

>> x=[3 1 7 5];


>> x=[3,1,7,5];
>> a=[3-2 6]
a =
1
6
>> x
x =
3
1
7
5
>> x(3)
ans =
7
>> x(3)=9
x =
3
1
9
5
>> x(3)=7
x =
3
1
7
5
>> 3+x(2)
ans =
4
>> y=3:7
y =
3
4
5
6
7
>> z=3:2
z =
Empty matrix: 1-by-0
>> y=3:2:7
y =
3
5
7
>> y=3:2:8
y =
3
5
7
>> z=1:0.1:1000;
>> whos
Name
Size
Bytes Class
Attributes
a
1x2
16 double
ans
1x1
8 double
x
1x4
32 double
y
1x3
24 double
z
1x9991
79928 double
>> z=10:-2:5
z =
10
8
6
>> a=0.1
a =
0.100000000000000
>> f=0.5:a:1
f =
Columns 1 through 4
0.500000000000000
0.600000000000000
0.700000000000000
0.800000000000000
Columns 5 through 6
0.900000000000000
1.000000000000000
>> format
>> f=0.5:a:1
f =

0.5000
0.6000
0.7000
0.8000
>> d=linspace(1,5,6)
d =
1.0000
1.8000
2.6000
3.4000
>> x
x =
3
1
7
5
>> x(1:3)
ans =
3
1
7
>> x(1:2:3)
ans =
3
7
>> x(4:-1:1)
ans =
5
7
1
3
>> x(4:-2:1)
ans =
5
1
>> x
x =
3
1
7
5
>> y=x(2:3)
y =
1
7
>> x
x =
3
1
7
5
>> b=[x(2:3) x(1) x(2) x(4)+10]
b =
1
7
3
1
15
>> b(8)
??? Index exceeds matrix dimensions.
>> b(8)=9
b =
1
7
3
>> b(2)=[]
b =
1
3
1
>> b(1:2:7)=[]
b =
3
15
0
>> n=length(b)
n =
3
>> length(x)
ans =
4
>> whos
Name
Size
a
1x1
ans
1x1
b
1x3
d
1x6
f
1x6
n
1x1
x
1x4

15

15

Bytes
8
8
24
48
48
8
32

Class
double
double
double
double
double
double
double

0.9000

1.0000

4.2000

5.0000

Attributes

y
z

1x2
1x3

16
24

double
double

>> f
f =
0.5000
0.6000
>> f(1:2:length(f))
ans =
0.5000
0.7000
>> f(1:2:end)
ans =
0.5000
0.7000
>> x
x =
3
1
7
>> x>2
ans =
1
0
1

0.7000
0.9000
0.9000
5
1

0.8000

0.9000

1.0000

You might also like