Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Matlab Matrix Referencing elements

% bai tap 1 
a1=10/2\5-3+2*4
b1=3^2/4
c1=3^2^2
d1=2+round(6/9 + 3*2)/2-3
e1=2+floor(6/11)/2-3
f1=2+ceil(-6/9)-3
g1=fix(-4/9)+fix(3*(5/6))
% bai tap 2
a2=mod(36,15)
b2=rem(36,15)
c2=gcd(36,15)
d2=lcm(36,15)
% bai tap 3
a3=1 & -1
b3=13 & (-6)
c3=0<-20
d3=0<=0.2<=0.4
e3=5>4>3
f3=2>3&1
% bai tap 4
x4=[3 1 5 7 9 2 6]
a4=x4(3)
b4=x4(1:7)
c4=x4(1:end)
d4=x4(1:end-1)
e4=x4(6:-2:1)
f4=x4([1 6 2 1 1])
g4=sum(x4),min(x4),max(x4)
% bai tap 5, so sánh từng phần tử của x5 với y5, nếu đúng trả về 1, sai trả về 0 
x5=[1 5 2 8 9 0 1]
y5=[5 2 2 6 0 0 2]
a5=x5>y5 
b5=y5<x5 
c5= x5==y5 
d5 = x5<=y5
e5 = y5>=x5
f5 = x5|y5
g5 = x5&y5
h5 = x5&(-y5)
i5=(x5>y5)|(y5<x5)
j5=(x5>y5)&(y5<x5)
% bài 6
x6=[1 0 2]
y6=[0 2 2]
x6=y6
b6=x6<y6
c6= x6<y6<x6 
d6 = x6<y6<y6
e6 = x6 | (x6)
f6 = y6&(y6)
x6=y6==x6
% bài 7
x7=1:10
y7=[3 1 5 6 8 2 9 4 7 0]
a7=(x7>3)&(x7<8)
b7=x7(x7>5)
c7=y7(y7<4)
d7=x7(x7<2)|(x7>=8)
e7=y7(x7<2)|(x7>=8)
f7=x7(y7<0)
% bài 8
x8=[1 4 8]
y8 = [2 1 5]
z8=[2 7 9 7;3 1 5 6;8 1 2 5]
a8=[x8;y8]
b8=z8(:,[1 4])
c8=z8([2 3],[3 1])
d8=z8(:)
% bài 13
x13=[1 4 8]
y13 = [2 1 5]
z13=[3 1 6;5 2 7]
a13=x13+y13
b13=z13-3
% bài 14
x14=[2 7 9 7;3 1 5 6;8 1 2 5]
a14=x14'
b14=sum(x14)
c14=sum(x14')
d14=sum(x14, 2)























Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.