[ncl-talk] comparing 2 arrays

Mary Haley haley at ucar.edu
Tue Dec 26 11:46:28 MST 2017


Ehsan,

Since these are 1D arrays, you can use the "ind" function to get the
locations where the two arrays are equal:

ii = ind(RV1.eq.RV2)

Then, to write out only the equal values, use "ii" to index all of the
arrays you are passing to alist:

 alist =
[/stidV1(ii),icaoV1(ii),stnmV1(ii),latV1(ii),lonV1(ii),hiV1(ii),dateV1(ii),RV1(ii),RGV1(ii),RGV2(ii)/]

​--Mary
​


On Sun, Dec 24, 2017 at 1:49 AM, Ehsan Taghizadeh via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hi,
> I want to read 2 files (text) and in case of equality of elements, write
> their columns in another file; I mean I want to match some elements of
> these 2 files.
>
> My problem is related to put the condition without do loop, because of its
> low speed. I'll be thankful if I could have your help about it.
> I've attached the input files and the script. How could I use the
> condition in lines 48-51 instead of lines 44-45 of the script? (However
> maybe it isn't necessary in this case.)
>
> *Sincerely*
> *Ehsan*
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171226/61acdce9/attachment.html>


More information about the ncl-talk mailing list