Plotting the Complex spectrum of a converted signal
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
Star Strider
il 25 Set 2020
Whatever ’P’ is, is missing, however that is of no consequence.
figure
fplot(real(AE))
hold on
fplot(imag(AE))
hold off
grid
legend('Re','Im')
.
4 Commenti
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)
.
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!