You are on page 1of 14

>> a1=12:20;

>> a1([1 3 7])


ans = 12 14 18

>>a=magic(5) >> a(1:3,2)


>>a([1 2 4], 2)
>>a([1 3], [2 4])
i:end
i
.
>> a(2,2:end)
>> a(2,2:end)

: ,

>>a(2, :)
ans =3 32 7 21 23 25
-
>>a2 =[1 3
4 2]
a2(:)
ans = >>a2(3)
1 ans =
4 3
>> a2(end)
3
ans =
2 2

>>b=1:10;
>>b(b>5)
>>ans =
6 7 8 9 10

a=magic(4);
a(a>8)

>> a=magic(4)
>> a(2:3,1:2)
>> a1=[11 7; 8 5]
>> a(2:3,1:2)=a1

>> a(3,:)=[]

>> A+2 >> A.^2
>> A-3 >> A.^(-1)
>> A+2==2+A >> 1./A==A.^(-1)
>> 3*A >> A.
>> A/3 >> B.
>> 3\A
>> A+B
>> A-B
>> A+B==B+A
>> A.*B
>> B.*A
>> A./B
>> B.\A



, /4.

>> sin([0:pi/4:pi])

3 4 ,
10*rand(3, 4),

.

>>log(10*rand(3,4))

find(_)
>> find(a>16)
min(a)
>> min(A)
max(a)
>> max(A)
>>max(A(:))
sum(a)
>>sum(A)
>>sum(A(:))
prod(a)
>>prod(A)

sort(a)
sort(a, mode)
>>sort(A,'ascend')
>> sort(A,'descend')

, MATLAB
.
MATLAB
(),

>>s1='Introduction to strings'
s1 =
Introduction to strings
>>s2='Paragraph one'
s2 =
Paragraph one

,
length
>>length(s1)

>> s1(1)
>> s1(1:9)
>> s1(11:16)

>>a='numperr
a=
numperr
>>a(7)=[]
a=
numper
>>a(4)='b'
a=
number
,
, , ,
>>s1(11:16)'
ans =
s
t
r
i
n
g
,

>> s3=['part', ' ', 'one']
s3 = part one

You might also like