function of two variables [message #1894] |
Thu, 17 March 1994 12:55 |
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
|
|
|