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

Home » Public Forums » archive » function of two variables
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
function of two variables [message #1894] Thu, 17 March 1994 12:55
brooker is currently offline  brooker
Messages: 12
Registered: March 1994
Junior Member
Hello from Canada!!

I have the following IDL question:

Assume I have the functions Y=2.*X + 3. and I want to plot Y vs X over the
range [0,10]

I could code this as

X=findgen(101)/100.*10.
Y=2.*X + 3.
plot,x,y

Very nice!! Only array operations. NO LOOPING!!!!!! Very FAST!!!!!

But what if now I had Z=2.*X + 3.*Y and I want to plot Z as X and Y both
range from 0 to 10. A way to code this is

X=findgen(101)/100.*10.
Y=X
num_y=n_elements(Y)
num_x=n_elements(X)
z=fltarr(num_x,num_y)
for j=0,numy-1 do begin
z(*,j)=2.*X + 3.*Y(j)
endfor
surface,Z,X,Y

Very inefficient because of the loop!! Very slow!!

Is there anyway to do this more efficiently?

Thanks,
Peter Brooker
brooker@toka.ireq-ccfm.hydro.qc.ca
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: adding widgets
Next Topic: !p.multi question: margin possible at top of page?

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

Current Time: Wed Oct 08 15:56:37 PDT 2025

Total time taken to generate the page: 0.00529 seconds