Question
Project in matlab. I have the correct ak value but not the correct ao value. My code is attached below also
2. Determine and plot the magnitude and phase spectrum of the Fourier series coefficients a, that is, plot ja, I as a functio
03 025 蓋0.2 0.15 0.1 o o5 ·10-8-6 4610 phase -2 -2
8- t= 0: .01:4; 9- to = 4; 10- fo =1/4; 11- j =sqrt (-1); 12- ao#1/4; 13-bo0; 14 15 16 17 18 19 %% Part 2 -10:10: 21 %ak ( (-
2. Determine and plot the magnitude and phase spectrum of the Fourier series coefficients a, that is, plot ja, I as a function of discrete frequencies Jok and La, as a function of discrete frequencies fok
03 025 蓋0.2 0.15 0.1 o o5 ·10-8-6 4610 phase -2 -2
8- t= 0: .01:4; 9- to = 4; 10- fo =1/4; 11- j =sqrt (-1); 12- ao#1/4; 13-bo0; 14 15 16 17 18 19 %% Part 2 -10:10: 21 %ak ( (-2-j ) ./ (3"p1. *k) ) + ( ( (-1) .^k) . / (pi. * k) ) ; the one i used stem (k, abs (ak)) 23 - 24 title ('magnitude); 25 xlabel ('k 26 ylabel ('ak'); 27-figure 28 29 stem(k,angle (ak)); 30 - 31 xlabel (' 32ylabel ('1/-ak); 33-figure title ('phase)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The reason why it is not getting plotted at K =0 is because you have a singularity while calculating a0 from ak and Matlab cannot resolve it and outputs NaN for k=0.

Therefore you need to wisely compute the value of a0 and assign it to the corresponding cell of the vector ak the procedure is given below as how to obtain a0 from ak

13 K 久ㅠ K K-90 ス万K small vahu small 3ǐ 1+ . 35 к -.. .as = 2 K, do ao . There tore Code Now plot th spechhum au anst x

Add a comment
Know the answer?
Add Answer to:
Project in matlab. I have the correct ak value but not the correct ao value. My code is attached ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Execute the function, using 11 as Non, and 8 as Noff. function fourier_example(Non,Noff) %this function demonstrates...

    Execute the function, using 11 as Non, and 8 as Noff. function fourier_example(Non,Noff) %this function demonstrates fourier analysis and synthesis for a simple %periodic rectangular wave of varying duty cycle. %Inputs: Non= integer number of seconds per period that the signal is on % Noff = integer number of seconds per period the signal is off t=-30:.001:30; %time scale Nharm = 20; %number of harmonics to calculate %construct a periodic square-wave with desired duty cycle x=zeros(size(t)); for k1=-Nharm:Nharm x =...

  • Can somebody help me with my matlab code? I am plotting the POWER SPECTRAL DENSITY OF...

    Can somebody help me with my matlab code? I am plotting the POWER SPECTRAL DENSITY OF Manchester, Polar, UNIPOLAR, and BIPOLAR. It wont run. The error I am getting is "incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform element wise multiplication, use '.*'. " clc; clear all; %Declaration of variables bandwidth = 1; total_bandwidth = 1/bandwidth; f = 0:.05*bandwidth:2*total_bandwidth; x=f*total_bandwidth; %Manchester Power...

  • Need help converting the following code from Matlab into Python: N=2048; fs=4.9; t=0:1/fs:(N-1)/fs; fs1=200; t1=0:1/fs1:(N-1)/fs1; x2=0.5+0.6366.*cos(2.*pi.*t1)+0.1273.*cos(10.*pi.*t1)-0.0909.*cos(14.*pi.*t1);...

    Need help converting the following code from Matlab into Python: N=2048; fs=4.9; t=0:1/fs:(N-1)/fs; fs1=200; t1=0:1/fs1:(N-1)/fs1; x2=0.5+0.6366.*cos(2.*pi.*t1)+0.1273.*cos(10.*pi.*t1)-0.0909.*cos(14.*pi.*t1); x=0.5+0.6366.*cos(2.*pi.*t)+0.1273.*cos(10.*pi.*t)-0.0909.*cos(14.*pi.*t); X=fftshift(fft(x)); f=linspace(-fs/2,fs/2,N); plot(f,abs(X)./N); xlabel('f'); ylabel('|F(f)|'); title('magnitude spectrum of sampled signal'); x1=ifft(fftshift(X)); figure plot(t(1:100),x1(1:100)); xlabel('t'); ylabel('f(t)'); title('f(t) obtained by inverse transform'); figure plot(t1(1:1000),x2(1:1000)); xlabel('t'); ylabel('f(t)'); title('original f(t)');

  • I wrote a Matlab program for the figure below. When I plot the waves, they look...

    I wrote a Matlab program for the figure below. When I plot the waves, they look the same. Why do the two waves frequencies look same and How do I avoid it? (I really do need this part of the question answered.) N = 200; % Total number of time domain samples in simulation. Fs = 100 ;% sampling frequency. F1 = 10; % frequency of wave - 1. F2 = 90; % frequency of wave - 2. phi =...

  • Hello, i have this matlab code where i have to track a red ball from and...

    Hello, i have this matlab code where i have to track a red ball from and uploaded video, and plot its direction in x-y direction My Question is how can i add x vs time plot and y vs time plot in this code. Thank you if exist('V','var') delete(V); end clear;clc; V=VideoReader('video.mp4'); figure(1); x=[];y=[]; i=1; while hasFrame(V) J=readFrame(V); figure(1);imshow(J);title(['Frame No. ',num2str(i)]); if (i>=28 && i<=132) bw=J(:,:,1)>200 & J(:,:,2)<80 & J(:,:,3)<80; bw=imfill(bw,'holes'); A=regionprops(bw,'Centroid'); x(end+1)=A.Centroid(1); y(end+1)=A.Centroid(2); hold on; plot(x,y,'*k');hold off; end i=i+1;...

  • MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax...

    MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax T(i)=t; if t>=(T0/2) while (t>T0/2) t=t-T0; end elseif t<=-(T0/2) while (t<=-T0/2) t=t+T0; end end if abs(t)<=(T0/4) y(i)=1; else y(i)=0; end i=i+1; end plot(T,y),grid, xlabel('Time (sec)'); title('y(t) square wave'); shg disp('Hit return..'); pause %--- a0=1/2; F(1)=0; %dc freq C(1)=a0; for n=1:Nmax a(n)=(2/(n*pi))*sin((n*pi)/2); b(n)=0; C(n+1)=sqrt(a(n)^2+b(n)^2); F(n+1)=n*f0; end stem(F,abs,(C)), grid, title(['Line Spectrum: Harmonics = ' num2str(Nmax)]); xlabel('Freq(Hz)'), ylabel('Cn'), shg disp('Hit return...'); pause %--- yest=a0*ones(1,length(T)); for n=1:Nmax yest=yest+a(n)*cos(2*n*pi*T/T0)+b(n)*sin(2*n*pi*T/T0);...

  • how to do laplace transform on a signal that is in frequency domain. I have a...

    how to do laplace transform on a signal that is in frequency domain. I have a signal that is in time domain and i used fft to plot it in the frequency domain, is there a way i could plot it in s domain. I know that i could do laplace transform directly from time domain to s domain, but I need to find out are these two results match each other. Fs = 4; % samples per second dt...

  • modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd...

    modify this code is ready % Use ODE45 to solve Example 4.4.3, page 205, Palm 3rd edition % Spring Mass Damper system with initial displacement function SolveODEs() clf %clear any existing plots % Time range Initial Conditions [t,y] = ode45( @deriv, [0,2], [1,0] ); % tvals yvals color and style plot( t, y(:,1), 'blue'); title('Spring Mass Damper with initial displacement'); xlabel('Time - s'); ylabel('Position - ft'); pause % hit enter to go to the next plot plot( t, y(:,2), 'blue--');...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

  • 1. Use the MATLAB command freqz to calculate the DTFT of System 1, to find its frequency response...

    1. Use the MATLAB command freqz to calculate the DTFT of System 1, to find its frequency response 0.25r[n] + 0.25r|n -2]. H(). For this exercise, System 1 has a different difference equation yn] Find H1 (w) for- aK π, with frequency steps of Δα-π/100. 2. Plot both the magnitude |H1(2)| and the phase LH1(w) vs w, for-π < ώ < π. Use abs and angle commands to obtain magnitude and phase. Label and title both plots and include in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT