Question

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 = 0; % zero phase signal.

t=0:(1/Fs):(N-1)/Fs; % time samples.

y1 =sin(2*pi*F1*t+phi); %first sinwave.

y2= sin(2*pi*F2*t+phi); %second sinwave

% plotting above functions in continuous and discrete time.

subplot 221; plot(t, y1); xlabel('Time in sec F1 = 10Hz'); ylabel('Amplitude'); grid on;

subplot 222; plot(t, y2); xlabel('Time in sec F2 = 90 hz'); ylabel('Amplitude'); grid on;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Original output by your code:

Why both waveform look same even frequency of both signal is different:

- we are sampling a sine wave signal with frequency of 100Hz.

- Frequency of first sine wave is 10Hz and as per Nyquist formula sampling frequency must be greater than equal to 2 time of highest frequency( fs >= 2*f). This condition is satisfied for first sine wave.

- In case of second sine wave, highest frequency is 90Hz and according to above formula sampling frequency must be greater than equal to 2*90 = 180Hz. But in this case it is not satisfied sampling frequency is 100Hz instead of 180Hz.

update code : Fs = 200 ;% sampling frequency.

- In above picture we can see both waveform is having different frequency. We have divided plot window in 2x2 part and we are using only first 2 part.

-We can divide into 2 part only in vertical part.

update code:

subplot (2,1,1); plot(t, y1); xlabel('Time in sec F1 = 10Hz'); ylabel('Amplitude'); grid on;

subplot (2,1,2); plot(t, y2); xlabel('Time in sec F2 = 90 hz'); ylabel('Amplitude'); grid on;

- As we are having very low sampling rate for high frequency sine wave. Due to that in above diagram you can see second sine wave is having different magnitude.

- To avoid this we can increase sampling frequency further

update code: Fs = 1000 ;% sampling frequency.

matlab code:

%//////////////////////////////////////////////////////////////////////////

N = 200; % Total number of time domain samples in simulation.
Fs = 1000 ;% sampling frequency.
F1 = 10; % frequency of wave - 1.
F2 = 90; % frequency of wave - 2.
phi = 0; % zero phase signal.
t=0:(1/Fs):(N-1)/Fs; % time samples.
y1 =sin(2*pi*F1*t+phi); %first sinwave.
y2= sin(2*pi*F2*t+phi); %second sinwave
% plotting above functions in continuous and discrete time.
subplot (2,1,1); plot(t, y1); xlabel('Time in sec F1 = 10Hz'); ylabel('Amplitude'); grid on;
subplot (2,1,2); plot(t, y2); xlabel('Time in sec F2 = 90 hz'); ylabel('Amplitude'); grid on;

%//////////////////////////////////////////////////////////////////////////

- code which I have changed is in BOLD TEXT

Add a comment
Know the answer?
Add Answer to:
I wrote a Matlab program for the figure below. When I plot the waves, they look...
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
  • 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...

  • Reproduce Figures 9.2b and 9.2c on MATLAB, assuming that the square wave (Figure 9.2b) is a...

    Reproduce Figures 9.2b and 9.2c on MATLAB, assuming that the square wave (Figure 9.2b) is a periodic symmetric square wave of normalized amplitude (A=1). Each student group should decide the power spectral density level of the channel noise. Compute the Fourier transform of the periodic square wave. clear all close all %%%% T=12*pi; %number of period x=linspace(0,T); t=x/pi y0=square(x); %square wave signal y0ft=fft(y0); %calculating Fourier Transformof signal y0fts=fftshift(y0ft); y0ftFinal=abs(y0ft); AWGN= rand(size(x)); %Calculating whit noise Att=(1/3); nSig= Att*AWGN; y=y0+nSig; %Square wave...

  • NB! This task is required to be solved in matlab. this task also requires the use...

    NB! This task is required to be solved in matlab. this task also requires the use of the function displayDualSpectrum(); which i have pasted in the bottom. the tasks that i need help with are A), B) and C). this is a multi-part question. Task - Frequency mixing We use a basic signal that can be described mathematically as follows: with this We shall then make an amplitude modulated signal: where fc is the carrier frequency. the code below specifies...

  • I need help in MATLAB. I'm working on a circuits lab report and I want to...

    I need help in MATLAB. I'm working on a circuits lab report and I want to plot the derivative of an input signal. The circuit is a differentiator OpAmp. It is receiving a triangle wave as an input and should output a square wave. (I've included my existing code.) The output formula is: Vout = -(Rf)*C*(dVin/dt) Where Rf is feedback resistance: Rf = 1*10^6; and C = 1*10^-6. EXISTING CODE: %% This section is copied, and then modified from another...

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

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

  • Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2...

    Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...

  • Wave Packets (a) Create a wave by adding two different waves by using Matlab, but different...

    Wave Packets (a) Create a wave by adding two different waves by using Matlab, but different combination than those we used in the class. Paste the output graph (and also the code). Any two waves can be chosen, but explain the difference compared to the original wave packet we obtained in the class. You can modify the code I used in the class, or build something from scratch. (b) Add as much waves as you want (minimum:3), using Matlab. Explain...

  • MATLAB code for a double pendulum. Please explain each lines for these codes pls. -------------------------------------...

    MATLAB code for a double pendulum. Please explain each lines for these codes pls. ---------------------------------------------------------------------------- clc close all clear all %---------Parameters------------------------------------------------------ L1=1; L2=1 ; M_1=2 ; M_2=1; G=9.8; %---------initial condition----------------------------------------------- tspan=30; theta1=3; theta1_prime=0; theta2=2.5; theta2_prime=0; y0=[theta1 theta1_prime theta2 theta2_prime]; [t,y]=ode45(@pend, [0 ,tspan],[ 3 0 2 0]); %---position of mass 1 and mass 2---------------------------------------- x1=L1*sin(y(:,1)); y1=-L1*cos(y(:,1)); x2=L1*sin(y(:,1))+l2*sin(y(:,3)); y2=-L1*cos(y(:,1))-l2*cos(y(:,3)); %------visualizing the result--------------------------------------------- figure(1) plot(x1,y1,'linewidth',2) hold on plot(x2,y2,'r','linewidth',2) h=gca; get(h,'fontSize') set(h,'fontSize',14) xlabel('X','fontSize',14); ylabel('Y','fontSize',14); title('Chaotic Double Pendulum','fontsize',14) fh = figure(1); set(fh, 'color', 'white'); figure(2)...

  • 6) Consider the below wave form when a-1 Hz (2n rad/sec) and b-0.9a F(t) sin(at)+sin(bt) I. Calcu...

    Please help, the plotting can be done in excel or matlab 6) Consider the below wave form when a-1 Hz (2n rad/sec) and b-0.9a F(t) sin(at)+sin(bt) I. Calculate the beat frequency. II. Plot the beat frequency II. What is the optimum sampling rate? IV. Calculate the time interval between samples at the optimum sampling rate 6) Consider the below wave form when a-1 Hz (2n rad/sec) and b-0.9a F(t) sin(at)+sin(bt) I. Calculate the beat frequency. II. Plot the beat frequency...

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