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
  • 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);...

  • 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...

  • Program from problem 1: (Using MATLAB) % Sampling frequency and sampling period fs = 10000; ts...

    Program from problem 1: (Using MATLAB) % Sampling frequency and sampling period fs = 10000; ts = 1/fs; % Number of samples, assume 1000 samples l = 1000; t = 0:1:l-1; t = t.*ts; % Convert the sample index into time for generation and plotting of signal % Frequency and amplitude of the sensor f1 = 110; a1 = 1.0; % Frequency and amplitude of the power grid noise f2 = 60; a2 = 0.7; % Generating the sinusoidal waves...

  • Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to d...

    Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to determine the frequency response of a signal or system by taking the Fourier Transform empirically (rather than computing it analytically). To do so we make use of the fft and fftshift commands. The fft command is an efficient implementation of the Discrete Fourier Transform (DFT) known as the Fast Fourier Transform (FFT). When the FFT is computed the samples are...

  • I need this program in MATLAB with different or another code. INPUT: x = [0 1...

    I need this program in MATLAB with different or another code. INPUT: x = [0 1 8 12 27]; y = [1 2 3 4 5]; nx = length(x); ny = length(y); n = length(x); if nx ~= ny display('Error. La cantidad de datos en x no es igual que los datos en y') end Sx = sum(x); Sxx = sum(x.^2); Sy = sum(y); Sxy = sum(x.*y); a1 = (n*Sxy - Sx*Sy)/(n*Sxx-(Sx)^2); a0 = (Sxx*Sy - Sxy*Sx)/(n*Sxx - (Sx)^2); m...

  • please help me with this MATLAB CODE and explain to me what each line does and...

    please help me with this MATLAB CODE and explain to me what each line does and what is used for? leave your comments as words, not as pictures. ..................................................................................................................................................................... clear all; close all; % For a script file, you better start with clear all and close all                        % However, for a fucntion, you better NOT to start                        % with them %% End of cell mode example %% Plot function t = 0:0.1:5; x1 = sin(2*5*t); x2 = cos(3*7*t);...

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
ADVERTISEMENT