Plotting complex sinusoid to a cosine wave

I have the complex exponential equation (z) and I want to adjust the plot to produce a cosine wave of amplitude of 5.0 that is shifted by 45 degrees. I have attached my code so far below. If someone could direct me to where I should make adjustments to plot a cosine wave with a = 5.0 shifted by 45 degrees that would be greatly appreciated. Thank you.
z = exp(-j*2*pi*t);
clear all; close all;
Tt = 1; % Total time
fs = 500; % Sampling frequncy
t = (0:1/fs:Tt); % Time vector
a = 5.0; % Amplitude
z = exp(-j*2*pi*t); % Complex sinusoid
plot(t,real(z),'k',t,imag(z),':k'); % Plot result
xlabel('Time (sec)', 'FontSize',14);
ylabel('y(t)','FontSize',14);

답변 (1개)

Star Strider
Star Strider 2023년 1월 15일
Add to the complex argument to shift the complex exponential result by 45°
Tt = 1; % Total time
fs = 500; % Sampling frequncy
t = (0:1/fs:Tt); % Time vector
a = 5.0; % Amplitude
z = exp(-1j*(2*pi*t+pi/4)); % Complex sinusoid
plot(t,real(z),'k',t,imag(z),':k'); % Plot result
xlabel('Time (sec)', 'FontSize',14);
ylabel('y(t)','FontSize',14);
.

댓글 수: 4

To plot to cosine wave with amplitude of 5.0 can I add a infront of exp(-1j*(2*pi*t+pi/4)); to make
z = a*exp(-1j*(2*pi*t+pi/4));
Thjat will work. I was concentrating more on getting the phase correct.
To amplify only the cosine curve, multiply the real part of ‘z’ by the real part of ‘a’ and the complex part of ‘z’ by the complex part of ‘a’ (that here is 0) —
Tt = 1; % Total time
fs = 500; % Sampling frequncy
t = (0:1/fs:Tt); % Time vector
a = 5.0; % Amplitude
z = exp(-1j*(2*pi*t+pi/4)); % Complex sinusoid
figure
plot(t,real(z)*real(a),'k',t,imag(z)*imag(a),':k'); % Plot result
xlabel('Time (sec)', 'FontSize',14);
ylabel('y(t)','FontSize',14);
Beyond that, I am not certain what you want to do.
.
ssmith
ssmith 2023년 1월 16일
Oh ok, so to follow the exact phrase, your method is correct, but my 'z' also works?
Not quite, since it multiplies both the real and imaginary parts of ‘z’ by ‘a’.
To be absolutely rigorous, the real and imaginary parts of ‘a’ need to be multiplied respectively by the real and imaginary parts of ‘z’.
Your Question specified that the cosine (real) part of the complex exponential function was to be multiplied by ‘a’. It just depends on how much detail (and how rigorously) you want to define this.
I leave that to your discretion.

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

카테고리

제품

릴리스

R2022b

질문:

2023년 1월 15일

댓글:

2023년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by