Re: Newbie question concerning summations/loops in IDL [message #61732] |
Wed, 30 July 2008 03:57  |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
On Jul 30, 4:33 am, Wox <nom...@hotmail.com> wrote:
> On Tue, 29 Jul 2008 23:19:19 -0700 (PDT), mbwel...@gmail.com wrote:
>> On Jul 29, 7:27 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
>>> On Jul 29, 1:12 pm, mbwel...@gmail.com wrote:
>
>>>> Hello,
>
>>>> I have need of some experienced users with sort of a newbie question.
>
>>>> I am writing a code that needs a summation in it, this is what I have
>>>> thus far:
>
>>>> v= ; volume of region
>>>> a= ; area of region
>>>> o= 60*!pi/180 ; fault dip angle
>>>> g= ; scaling factor
>>>> t= 150 ; elastic lithosphere thickness
>>>> h= ; depth of faulting
>
>>>> ind_small = where(thaext[1,*] lt t)
>>>> ind_large = where(thaext[1,*] ge t)
>>>> thaext_small = thaext[*,ind_small]
>>>> thaext_large = thaext[*,ind_large]
>
>>>> ens=(sin(o)*cos(o)/v)* ; horizonatal normal strain for small faults
>>>> enl=(cos(o)/a)* ; horizonatal normal strain for
>>>> large faults
>>>> evs=(-sin(o)*cos(o)/v)* ; vertical normal strain for small faults
>>>> evl=(-cos(o)/a)* ; vertical normal strain for large faults
>
>>>> The summation needs to be after * in the ens, enl, evs and evl
>>>> fields.
>>>> It must be of the form:
>>>> summation N, i=0 [Di Li Hi] for small faults, where N = ind_small, Hi=
>>>> T/sin(o) and
>>>> summation N, i=0 [Di Li] for large faults, where N=ind_large
>
>>>> Could anyone provide any insight/guidance?
>
>>>> Thanks,
>>>> ~Matt
>
>>> I don't know what some of your variables are (Li? Di?), but you might
>>> want to look at TOTAL() to start- you can use that to do most
>>> summation tasks.
>
>> L and D are data from a ascii table that is already ready in, while i
>> is the indice of the summation. I've looked at total, but the examples
>> were sorely lacking. I was hoping that perhaps a useful example, given
>> my code and desire, could be supplied.
>
>> ~Matt
>
> I'm not sure what you mean with "summation N, i=0 [Di Li Hi] ... where
> N=ind_small". The index i goes from 0 to what? And what are you
> summing? D[i]*L[i]*H[i]?
Okay, if I understand it correctly, then what you're saying is that in
ind_small you multiply by an extra factor of t/sin(o) inside the sum,
but not in ind_large?
H = replicate(1., n_elements(D))
H[ind_small] = t/sin(o)
summation = total(D*L*H)
Is that what you're looking for?
(by the way, look up !RADEG).
-Jeremy.
|
|
|