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

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

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

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

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

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