Plotting the Complex spectrum of a converted signal

3 visualizzazioni (ultimi 30 giorni)
My goal in this program is to plot the complex spectrum of multiple signals after they are converted into complex exponentials.
syms t
a = 10 * pi * t + 20;
b = 12 * pi * t - 40;
c = 15 * pi * t + 60;
A = rewrite(8 + 6*cos(a) - 3*cos(b) + 10 *sin(c) ,'exp')
AE = expand(A)
This gives me a desired output however whenever I try to plot the complex spectrum using
k = linspace(0,10);
r = subs(P, t, k)
Then I run into issues. Is there a more direct approach where I can take A or AE and directly plot the complex spectrum ? Or does AE need to be converted into a matrix and then plotted?
The current error I run into when trying to plot the complex spectrum like I normally do is this
% Error using plot
% Data must be numeric, datetime, duration or an array convertible to double.

Risposte (1)

Star Strider
Star Strider il 25 Set 2020
Whatever ’P’ is, is missing, however that is of no consequence.
Use the fplot function to do the plotting:
figure
fplot(real(AE))
hold on
fplot(imag(AE))
hold off
grid
legend('Re','Im')
.
  4 Commenti
David Wisniewski
David Wisniewski il 25 Set 2020
Thank you I am just starting out in DSP when I say line segments I mean in this form I am still working on the vocabulary.
Star Strider
Star Strider il 25 Set 2020
That is a stem plot. There is no ‘fstem’ function, so it takes a bit of handle magic to get the data and then plot it:
syms t
a = 10 * pi * t + 20;
b = 12 * pi * t - 40;
c = 15 * pi * t + 60;
A = rewrite(8 + 6*cos(a) - 3*cos(b) + 10 *sin(c) ,'exp')
AE = expand(A)
figure
fplot(real(AE))
hold on
fplot(imag(AE))
hold off
grid
legend('Re','Im')
Ax = gca; % Define Axes Handle
Lines = Ax.Children; % Get Line Handles
t1 = Lines(1).XData; % Imaginary Part ‘x’ Value
t2 = Lines(2).XData; % Real Part ‘x’ Value
y1 = Lines(1).YData; % Imaginary Part ‘y’ Value
y2 = Lines(2).YData; % Real Part ‘y’ Value
figure
stem(t2, y2, 'MarkerSize',2)
hold on
stem(t1, y1, 'filled', 'MarkerSize',5)
hold off
legend('Re','Im')
xlim([-0.05 0.05]) % View Details Near Origin (Optional)
.

Accedi per commentare.

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by