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

Home » Public Forums » archive » Re: function of two variables
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: function of two variables [message #1885] Mon, 21 March 1994 06:01 Go to previous message
black is currently offline  black
Messages: 39
Registered: August 1992
Member
In article <CMtu54.5o@ireq.hydro.qc.ca>,
<brooker@toka.ireq-ccfm.hydro.qc.ca> wrote:

[Stuff deleted]

> 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

What you need are two two dimensional arrays that contain X and Y values. The
size of number of X co-ords by number of Y co-ords. These arrays essentaially
stor the X & Y values at each point on the grid. So the value in the elements in
the X array change in one direction say along the rows, but stays consatnt in the
other direction. The Y array does the opposite. Given that the Y=X in your code
you only need to come up with one array, since Y is the transpose of X.

So the next trick is to come up with the X array. This is simply done by taking
your existing X array and using the matrix multiply in the following way

1) create a 1d array that contains 1 of the size required - the number of Y
indices call this UNITY

2) do X#UNITY.

This does what you want.

John Black.
[Message index]
 
Read Message
Read Message
Previous Topic: Structures and Call_External
Next Topic: Question about shade_surf and Postscript output

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

Current Time: Sat Oct 11 06:26:39 PDT 2025

Total time taken to generate the page: 0.24643 seconds