clear all; close all
%% ex 2.1
n = [-5:5]
x = zeros(1,length(n));
for i=1:length(n)
if n(i)>=0 && n(i)<=3
x(i) = 2;
end
end
display(x)
%% ex 2.2
figure()
stem(n,x)
xlabel('n');ylabel('x[n]');
%% ex 3.1
y_n = x(2:end) - x(1:end-1)
%% ex 3.2
figure()
stem(n(2:end), y_n)
xlabel('n');ylabel('y[n]');
%% ex 3.3
Ts = 1/500;
t = 0:Ts:0.1-0.002;
f_sin = cos(2*pi*10*t);
%% ex 3.4
figure()
stem(t, f_sin)
xlabel('n');ylabel('x[n]');
%% ex 3.5
y_analyt = -20*pi*sin(2*pi*10*t);
%% ex 3.6
f_sin_copy = [cos(2*pi*10*(-0.002)), f_sin, cos(2*pi*10*0.1)];
y_num = (f_sin_copy(3:end)-f_sin_copy(1:end-2))./(2*Ts);
%% ex 3.7
figure()
subplot(2,1,1);
stem(t, y_analyt)
xlabel('n');ylabel('Analytical y[n]');
subplot(2,1,2);
stem(t, y_num)
xlabel('n');ylabel('Numerical y[n]');
%% ex 4.1
A = [3 2 -4; 2 -1 1; -4 1 2];
b = [8 2 -3]';
x2 = linsolve(A, b)
%% ex 4.2
n2 = [-1:5];
x2 = zeros(1,length(n2));
for i=1:length(n2)
if n2(i)>=0 && n2(i)<=3
x2(i) = 2;
end
end
y_n2_back = x2(2:end) - x2(1:end-1)
%% ex 4.3 and ex 4.4
A_num = zeros(length(x2)-1,length(x2));
for i = 1:length(x2)-1
A_num(i,i) = -1;
A_num (i, i+1) = 1;
end
y_n2_mat = A_num*x2'
% visualize results
figure()
subplot(2,1,1);
stem(n2(2:end), y_n2_back)
xlabel('n');ylabel('Backward Difference y[n]');
subplot(2,1,2);
stem(n2(2:end), y_n2_mat)
xlabel('n');ylabel('Linear Equations y[n]');
Example Of Report On Matlab Code For Each Exercise:
Cite this page
Choose cite format:
- APA
- MLA
- Harvard
- Vancouver
- Chicago
- ASA
- IEEE
- AMA
WowEssays. (2021, December, 27) Example Of Report On Matlab Code For Each Exercise:. Retrieved November 22, 2024, from https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/
"Example Of Report On Matlab Code For Each Exercise:." WowEssays, 27 Dec. 2021, https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/. Accessed 22 November 2024.
WowEssays. 2021. Example Of Report On Matlab Code For Each Exercise:., viewed November 22 2024, <https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/>
WowEssays. Example Of Report On Matlab Code For Each Exercise:. [Internet]. December 2021. [Accessed November 22, 2024]. Available from: https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/
"Example Of Report On Matlab Code For Each Exercise:." WowEssays, Dec 27, 2021. Accessed November 22, 2024. https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/
WowEssays. 2021. "Example Of Report On Matlab Code For Each Exercise:." Free Essay Examples - WowEssays.com. Retrieved November 22, 2024. (https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/).
"Example Of Report On Matlab Code For Each Exercise:," Free Essay Examples - WowEssays.com, 27-Dec-2021. [Online]. Available: https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/. [Accessed: 22-Nov-2024].
Example Of Report On Matlab Code For Each Exercise:. Free Essay Examples - WowEssays.com. https://www.wowessays.com/free-samples/example-of-report-on-matlab-code-for-each-exercise/. Published Dec 27, 2021. Accessed November 22, 2024.
Copy