comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » For..Do loop. IDL Beginner
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: For..Do loop. IDL Beginner [message #93795 is a reply to message #93793] Tue, 18 October 2016 03:50 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 10/18/2016 11:39 AM, Nikola Vitas wrote:
> On Tuesday, October 18, 2016 at 12:46:43 AM UTC+1, Cheryl wrote:
>> I am trying to plot the following using For.. Do loop.
>>
>> i. x, y2 ; psym = -4
>> ii. x, y3 ; psym = -5
>> iii. x, y4; psym = -6
> From your question is not very clear what you want to do and why. I
> guess your problem is that y's are different functions with different
> number of elements so that you have to deal with different variable
> names in a loop.
>
> Here is a quick solution that may help you to move forward. (Note
> that the EXECUTE command should be used with extra caution - read IDL
> help on it!.)
>
> syms = [-4, -5, -6]
> for i = 0, N_ELEMENTS(syms)-1 DO BEGIN
> IF i eq 0 THEN cmd = 'plot' ELSE cmd = 'oplot'
> log = EXECUTE(cmd + ', x, y'+strcompress(string(i), /rem)+', psym = syms[i]')
> ENDFOR
easiest is

g=plot(x, y2, psym = -4)
void=plot(x, y3, psym = -5, overplot=g)
void=plot(x, y4, psym = -6, overplot=g)

if it needs to be a loop, eighter use EXECUTE, or

p=ptrarr(3)
*p[0]=y2
*p[1]=y3
*p[2]=y4
g=!null
for i=0,2 do g=plot(x,*p[i],psym=-3-i,overplot=g)

You probably could use a LIST or another data type as well instead of
pointers, if you prefer.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fitting plasma waveforms with 10^6 variable combos!
Next Topic: smooth() bug in (at least) version 8.5.1

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:26:00 PDT 2025

Total time taken to generate the page: 0.00190 seconds