stem command working on the oppisite side of the axis
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to create a plot of low pass filter ,while the Y axis is in dB and x is the ferquincy in logaritmich scale. I made the plot and now I want using the stem command to point to the cufoff ferquincy . but for some reason when I want to point to the cut off ferquincy the stem comand making the line from the up and not from down . how to fix this problem ?
clc
close all;
y=mag2db(dB_axes(1:120));
x=f_axes(1:120);
for i=1:length(mag2db(y(1:120)))
if(2.8<abs(y(i)) && abs(y(i))<3.5 )
i; %% find the cutoff ferquincy
break;
end;
end
plot(x,y,'red','linewidth',3);
grid on;
set(gca, 'XScale', 'log');
hold on
stem(x(i),y(i),'*','linewidth',2);
xlabel('f[logarthmic scale]');
ylabel('dB');
title('RC filter -freuquincy responce');
0 comentarios
Respuestas (2)
Star Strider
el 24 de Abr. de 2021
It is necessary to give stem a different base value in order for it to plot upwards to a negative value.
Try this —
s = tf('s');
sys = 1/(s^2+2*s-5);
[a,p,w] = bode(sys);
bw = bandwidth(sys);
asq = squeeze(a);
hppa = interp1(w, mag2db(asq), bw);
figure
semilogx(w, mag2db(asq))
hold on
stem(bw, hppa, 'BaseValue',min(mag2db(asq)))
hold off
grid
.
0 comentarios
Clayton Gotberg
el 24 de Abr. de 2021
This is because you haven't provided any information about the baseline for stem, so the function assumes you want it to come from y = 0. To adjust it to come from the bottom of the chart, use this:
ax = gca;
y_min = min(ax.Ylim)
stem(x(i),y(i),'*','linewidth',2,'BaseValue',y_min);
0 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!