Đ M NH Tùng-B21DCVT451
Đ M NH Tùng-B21DCVT451
Đ M NH Tùng-B21DCVT451
x=[1,-3,3,14,-10,12];
y=[12,6,0,-1,-10,2];
res1=x&y
res2=x|y
res3=x>y
Bai 8:
C=[1 2 3 4 10;-22 1 11 -12 4;8 1 6 -11 5;18 1 11 6 4];
res1=C<=10;
C=C.*res1;
res2=C>=-10;
C=C.*res2;
disp(C);
Bai 9:
t=[0:0.1:10];
s=sin(2*pi*5*t).*cos(2*pi*3*t)+exp(-0.1*t);
plot(t,s);
Bai 10:
t=[0:0.1:10];
s=sin(2*pi*5.3*t).*sin(2*pi*5.3*t);
plot(t,s);
Bai 11:
t=[0:0.1:10];
s=round(20*sin(2*pi*5*t));
plot(t,s);
Bai 12:
b=[1024 1000 100 2 1];
res1=log2(b)
res2=log10(b)
Bai 13:
w = 0.01:0.01:5;
H1 = 1./(1j.*w);
H2 = 1./(1+1j.*w);
figure;
subplot(2,3,3);
loglog(w, abs(H1));
title('Log-log: |H1|');
xlabel('Frequency (w)');
ylabel('Magnitude');
subplot(2,3,6);
loglog(w, abs(H2));
title('Log-log: |H2|');
xlabel('Frequency (w)');
ylabel('Magnitude');
subplot(2,3,1);
semilogx(w, abs(H1));
title('Semilogx: |H1|');
xlabel('Frequency (w)');
ylabel('Magnitude');
subplot(2,3,4);
semilogx(w, abs(H2));
title('Semilogx: |H2|');
xlabel('Frequency (w)');
ylabel('Magnitude');
subplot(2,3,2);
semilogy(w, abs(H1));
title('Semilogy: |H1|');
xlabel('Frequency (w)');
ylabel('Magnitude');
subplot(2,3,5);
semilogy(w, abs(H2));
title('Semilogy: |H2|');
xlabel('Frequency (w)');
ylabel('Magnitude');
Bai 14:
w = 0.01:0.01:5;
H1 = 1./(1j.*w);
H2 = 1./(1+1j.*w);
w = 0.01:0.01:5;
H1 = 1./(1j.*w);
H2 = 1./(1+1j.*w);
figure;
% Biên ??
subplot(2,1,1);
plot(w, abs(H1), 'b', w, abs(H2), 'r');
title('Biên ??');
xlabel('Frequency (w)');
ylabel('Magnitude');
legend('|H1|', '|H2|');
% Pha
subplot(2,1,2);
plot(w, angle(H1), 'b', w, angle(H2), 'r');
title('Pha');
xlabel('Frequency (w)');
ylabel('Phase');
legend('arg(H1)', 'arg(H2)');
Bai 15:
x=[-2:0.2:2];
y=[-1:0.1:1]';
v=ones(length(x),1);
X=v*x;
Y=y*v';
f=X.^2+Y.^2;
mesh(x,y,f)
Bai 16:
radius = 3;
[x, y, z] = sphere(50);
x = x * radius;
y = y * radius;
z = z * radius;
surf(x, y, z);
axis equal;
Bai 17:
y = 1:0.5:5;
yr = fliplr(y);
z = round(y);
disp('y =');
disp(y);
disp('yr =');
disp(yr);
disp('z =');
disp(z);
>> baitap17
y =
1.0000 1.5000 2.0000 2.5000 3.0000
3.5000 4.0000 4.5000 5.0000
yr =
5.0000 4.5000 4.0000 3.5000 3.0000
2.5000 2.0000 1.5000 1.0000
z =
1 2 2 3 3 4 4 5 5
Bai 18:
color = struct('red', [], 'blue', [], 'green', []);
disp(colorStruct);
>> baitap18
1x20 struct array with fields:
red
blue
green
Bai 19:
r = 3;
chuVi = 2 * pi * r;
dienTich = pi * r^2;
axis equal;
Bai 20:
r = 3;
chuVi = 2 * pi * r;
dienTich = pi * r^2;
axis equal;
f =
@(x)x^3/3+4*x^2+x-6
>> [x,count]=baitap21(0,3,0.00001,f)
x =
1.0646
count =
19