difference between these 2 graphs when i put (-acos) and when i put (acos only)

조회 수: 1 (최근 30일)
kay Dee
kay Dee 2020년 2월 26일
댓글: darova 2020년 2월 26일
Hello Guys
Here is a code that i built of trying to plot a sine wave signal by using two methods:
1) 1st method was by a sine wave from certain parameters (cf code below)
2) the second method was looking from the plot of the first question and rebuilding the same sine wave by extracting the (Frequency , Amplitude and phase ) values which i managed to do
question
when calculating the phase i used -acos instead of cos to match the 2nd wave with the 1st one , but when i use cos only the signal is delayed(cf the plots below) . can you please tell me why this is giving me a delayed plot on (acos) when theoritacally it should give me the same plot ?
please check my code and plot below
%1st method just initialising the signal values and ploting
clear all;
close all;
clc;
t=linspace(-0.5,2,1000);
s1=sqrt(624)*cos(linspace(-7.5,27,1000));
%2nd method looking from the plot of the first signal and rebuilding
%the signal by using the sine wave parameters . (Frequency ,Amplitude and phase)
f=2.2; % frequency from the plot en Hz
a=find(t>=0); % creation of the 1st value>0 from the time space
Phi=-acos((s1(a(1)))/max(s1)) % Phi is calculated when t=o from the {s1=cos(2*pi*f*t + phi)}
% Phi=-acos(s1(t=0)) or Phi=acos(s1(t=0)){when i use cos instead of -cos the signal is delayed [why?]}
s2=max(s1)*cos(2*pi*f*t+Phi);
plot(t,s1), hold on
plot(t,s2,'r')
xlabel('Temps (s)'), ylabel('Signal sl(t)')
legend('Signal source', 'Signal reconstruit'
  댓글 수: 1
darova
darova 2020년 2월 26일
I don't know what are you doing but Phi is just shift if phase
s2=max(s1)*cos(2*pi*f*t+Phi);
So you can move you cos() whatever you want with Phi

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by