Can I please have help fixing my matlab code. I have attached all the work leadi
ID: 2268450 • Letter: C
Question
Can I please have help fixing my matlab code. I have attached all the work leading up to it along with the question itself. I need help with the code since i dont believe it is correct and i get some errors when i run the code. The code is also incomplete so could you help me complete it. Could it please be typed because some handwriting is really hard to understand. Thank you.
%MatLab code for first half of the graphs:
close all;
clear all;
clc;
% (a) exponential wave
T = 1;
w = 2*pi/T;
for k = 1:51
C(k) = (exp(1-1j*w*(k-1))-1)/(1-1j*w*(k-1));
end
figure;
stem(0:50,abs(C),'fill');
grid;
xlabel('k');
ylabel('Amplitude');
title('C(k)');
t = 0:0.01:5;
N = [5 15 50];
for p = 1:length(N)
for i=1:length(t)
for k = 1:N(p)
x(i,k) = C(k) * exp(1j*(k-1)*(2*pi/T)*t(i));
end
y (i) = sum(x(i,:));
end
%Plot with lables
figure;plot(t,y);grid;xlabel('Time');ylabel('Amplitude');title('Approximation');
end
% (b) square wave
% close all;
clear all;
clc;
T = 1;
w = 2*pi/T;
for k = 1:51
C(k) = (exp(-j*w*(k-1)/2)-1)^2/(2*j*w*(k-1));
end
C(1) = 0;
figure;stem(0:50,abs(C),'fill');grid;xlabel('k');ylabel('Amplitude');title('C(k)');
t = 0:0.01:5;
N = [5 15 50];
for p = 1:length(N)
for i=1:length(t)
for k = 1:N(p)
x(i,k) = C(k) * exp(1j*(k-1)*(2*pi/T)*t(i));
end
y (i) = sum(x(i,:));
end
figure;plot(t,y);grid;xlabel('Time');ylabel('Amplitude');title('Approximation');
end
Consider a Hilbert space, H, a complete orthogonal set, B, where B = {bi,b2,by, this chapter, it was shown that ) H and VBcH In ! where and the set, {, 2,3, ), is referred to as the generalized Fourier Series 3. Without using Matlab, derive an expression for the exponential Fourier series for the follow- ing signals: ft)-(-1 1 0StExplanation / Answer
close all;
clear all;
clc;
% (a) exponential wave
T = 1;
w = 2*pi/T;
for k = 1:51
C(k) = (exp(1-1j*w*(k-1))-1)/(1-1j*w*(k-1));
end
figure;
stem(0:50,abs(C),'fill');
grid;
xlabel('k');
ylabel('Amplitude');
title('C(k)');
t = 0:0.01:5;
N = [5 15 50];
for p = 1:length(N)
for i=1:length(t)
for k = 1:N(p)
x(i,k) = C(k) * exp(1j*(k-1)*(2*pi/T)*t(i));
end
y (i) = sum(x(i,:));
end
%Plot with lables
figure;plot(t,y);grid;xlabel('Time');ylabel('Amplitude');title('Approximation');
end
% (b) square wave
% close all;
clear all;
clc;
T = 1;
w = 2*pi/T;
for k = 1:51
C(k) = (exp(-j*w*(k-1)/2)-1)^2/(2*j*w*(k-1));
end
C(1) = 0;
figure;stem(0:50,abs(C),'fill');grid;xlabel('k');ylabel('Amplitude');title('C(k)');
t = 0:0.01:5;
N = [5 15 50];
for p = 1:length(N)
for i=1:length(t)
for k = 1:N(p)
x(i,k) = C(k) * exp(1j*(k-1)*(2*pi/T)*t(i));
end
y (i) = sum(x(i,:));
end
figure;plot(t,y);grid;xlabel('Time');ylabel('Amplitude');title('Approximation');
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.