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

Plotting figures in a for loop - please help!

0 views
Skip to first unread message

Ian Davis

unread,
Nov 24, 2009, 4:36:06 PM11/24/09
to
Hi all,

Having some trouble getting this piece of code to work. Basically I'm running a for loop at the end of a long script, and I want it to plot a new figure at each iteration of the loop.

All variables have previously been declared, the loop however is only running one iteration and plotting the first figure only.

Any ideas would be much appreciated!

for m = 1:length(p1)

for n = 1:length(p2)

pw = reshape(20*log10(real(p_wem(m,n,:))/2e-5),length(kR),1);
pa = reshape(20*log10(real(p_analytical(m,n,:))/2e-5),length(kR),1);

figure
plot(kR,pw)
hold on
plot(kR,pa,'r')
drawnow
xlabel('kR')
ylabel('SPL (dB)')
legend('WEM','Analytical','Location','EastOutside')
title(['Receiver ',int2str(n),' of MD Ring ',int2str(m)])

end

end

dpb

unread,
Nov 24, 2009, 4:47:46 PM11/24/09
to
Ian Davis wrote:
> Hi all,
>
> Having some trouble getting this piece of code to work. Basically I'm
> running a for loop at the end of a long script, and I want it to plot a
> new figure at each iteration of the loop.
> All variables have previously been declared, the loop however is only
> running one iteration and plotting the first figure only.
>
> Any ideas would be much appreciated!
>
> for m = 1:length(p1)
> for n = 1:length(p2)
>
...

W/ what's shown one must presume length(p1)==length(p2)=1

--

0 new messages