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

1 次查看(过去 30 天)
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