Is there anything wrong? % Exercise 2A % clear all N = [3 8 15]; for i=1:length(
ID: 2291142 • Letter: I
Question
Is there anything wrong?
% Exercise 2A % clear all N = [3 8 15]; for i=1:length(N) % Calculate Grammian gram = hilb(N(i)); b = zeros (N(i),1); for k = 0:N(i)-1; F = @(t)t.^k.*exp(t); b(k+1) = quad(F,0,1); end; % Calculate the generalized Fourier Series alpha = gram % Calculate the projection t = (0:0.01:1).'; f = exp(t); basis = zeros(length(t),N(i)); for k = 0:N(i)-1 basis(:,k+1) = t.^k; end proj = basis * alpha; % Plot Figure
figure(1)
subplot(3,1,i), stem(0:N(i)-1,alpha) title('GFS Coefficients for exp(t)') xlabel('Coefficient number') ylabel('Coefficient Value') grid on
figure(2)
subplot(3,1,i), plot(t,proj, t, f) title('Projection and exp(t)') xlabel('Amplitude') ylabel('t') legend('Projection','exp(t)') grid on end % Exercise 2A % clear all N = [3 8 15]; for i=1:length(N) % Calculate Grammian gram = hilb(N(i)); b = zeros (N(i),1); for k = 0:N(i)-1; F = @(t)t.^k.*exp(t); b(k+1) = quad(F,0,1); end; % Calculate the generalized Fourier Series alpha = gram % Calculate the projection t = (0:0.01:1).'; f = exp(t); basis = zeros(length(t),N(i)); for k = 0:N(i)-1 basis(:,k+1) = t.^k; end proj = basis * alpha; % Plot Figure
figure(1)
subplot(3,1,i), stem(0:N(i)-1,alpha) title('GFS Coefficients for exp(t)') xlabel('Coefficient number') ylabel('Coefficient Value') grid on
figure(2)
subplot(3,1,i), plot(t,proj, t, f) title('Projection and exp(t)') xlabel('Amplitude') ylabel('t') legend('Projection','exp(t)') grid on end
2. Using MATLAB, the basis set r":0stsl.n 0,12, N-1 the hilb and the quad function, calculate the generalized Fourier series for the following signals: f(1)-e' /(1)-cos(2?1) a) for 0 1 1 for 0 0st
Explanation / Answer
Since you are checking for 2A. you need to replace t by 2t everywhere(like exp(t) by exp(2t)). Once you check with this changes if get any doubt than let me know.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.