Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add points on Bode plot

1,054 views
Skip to first unread message

Olivier

unread,
May 14, 2010, 12:03:06 PM5/14/10
to
Hello,

I have to add experimental data (points) on a bode plot in matlab but I don't know how to do. On other plots I would just do with hold on and plot(x,y), but here it doesn't work because the two plots are in one.

Hope my problem is clear.

Thank you.

us

unread,
May 14, 2010, 12:33:06 PM5/14/10
to
"Olivier " <quiqui...@hotmail.com> wrote in message <hsjs7q$7hr$1...@fred.mathworks.com>...

no... can you show a sparse(!) example...

us

Olivier

unread,
May 14, 2010, 4:15:21 PM5/14/10
to
So here is an example where I add some points on an already existing plot of a sine :

t = 0:0.1:4;
x = sin(t);
hold on
plot(y,t)
% I add an arbitrary point
plot(2,0.5,'s','MarkerFaceColor','g','MarkerEdgeColor','k')
hold off

Now my problem : I've got pairs of values (frequency,amplitude) and (frequency,phase). I would like to add them the same way on a bode plot. I tried the same as in the example, but it only appeared on the phase plot so I tried to mess with subplot but it didn't work.

So is there any way to "select" the amplitude plot to add some points there too?

Thank you.

MFjbj2

unread,
May 30, 2010, 9:50:15 AM5/30/10
to
Hi all.

This is exactly the same problem I'm trying to find a solution to. So all information would be appreciated.

See also the thread I created:
http://mathforum.org/kb/thread.jspa?threadID=2071466

Best regards.
Jon Bj.

James Schuller

unread,
Nov 13, 2010, 5:08:09 AM11/13/10
to
I had same problem, seems the data points always went to the phase plot. Found this thread while looking for solution.

I fixed this problem by simply using:

bodemag(g)
instead of
bode(g)

Then using the method you illustrate below allowed for data points to be added to magnitude plot. If you are still interested in the Phase plot you can simply right click on the figure that was made and make it visible (or probably write a line of code to make it visible after you add the data points).

James

"Olivier " <quiqui...@hotmail.com> wrote in message <hskb0p$mns$1...@fred.mathworks.com>...

Beefcake

unread,
Mar 13, 2012, 12:08:12 AM3/13/12
to
I found this link to be extremely useful, See OP's additional details part for easy solution.

"James Schuller" wrote in message <iblo28$k56$1...@fred.mathworks.com>...

Nathan Argetsinger

unread,
Mar 20, 2016, 2:05:09 PM3/20/16
to
"Olivier" wrote in message <hsjs7q$7hr$1...@fred.mathworks.com>...
For anybody still struggling with this.. Here is a script I wrote that plots experimental results on the bode magnitude and phase plots. It's not terribly clean but it does the job.


%%%BEGINNING OF SCRIPT%%%
clf

format long g
% K = [0.1, 0.3, 1, 5, 10];
omega_N = [.1, .3, .5, .8, 1, 3];
zeta = .3;

tao = 2*pi./omega_N;

for i = 1:length(tao)
[u, t] = gensig('sin',tao(i), 300);

sys = tf([1],[omega_N(2)^-2, 2*zeta*omega_N(2)^-1, 1]);




% end
figure(1);
subplot(3,2,i)

hold on
[sy, st] = lsim(sys, u, t);
plot(st, sy, t, u);
[pks, locs] = findpeaks(sy);
[sig_pks, sig_locs] = findpeaks(u);

plot(st(sig_locs), sig_pks, '*', t(locs), pks, 'o');
axis([0,t(sig_locs(4)), -2, 2])


% disp(findpeaks(t, u));
Y = max(abs(sy));
U = max(abs(u));
i;
phase = -((sig_locs(1) - locs(1))/(sig_locs(1) - sig_locs(2)))*360;

diff = (Y/U);
dB = mag2db(Y);
output = sprintf('input freq: %f\t dB: %f\t phase: %f\n', omega_N(i), dB, phase);
disp(output);
hold off



figure(2);
hold on
% subplot(2,1,1);
bodemag(sys);
plot(omega_N(i),dB, 's','MarkerFaceColor','g','MarkerEdgeColor','k');
figure(3);
hold on
bode(sys);
plot(omega_N(i), phase, 's');


end
title('Nates sine simulations');
0 new messages