Rank: 1361 based on 105 downloads (last 30 days) and 8 files submitted
photo

Zhigang Xu

E-mail
Company/University
Maurice Lamontagne Institute

Personal Profile:

 

Watch this Author's files

 

Files Posted by Zhigang Xu View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
10 Feb 2014 Two Matlab Functions for Understanding How Fast Fourier Transform Works Two m-functions, sfft and sifft, are supplied as plain text counterparts to the Matlab binary built- Author: Zhigang Xu sfft, sifft as readable cou... 21 0
05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu mathematics, set, unique, numunique, sort 5 10
  • 5.0
5.0 | 2 ratings
28 Aug 2009 tidal_ellipse Consists of two tidal ellipse conversion programs Author: Zhigang Xu tools, conversion, tidal ellipse, earth sciences 32 1
  • 4.0
4.0 | 1 rating
28 Aug 2009 Converts between decimal integers to multiple based numbers Converts between decimal integers to multiple based numbers. Author: Zhigang Xu mathematics, data structure, binary tree search, computer science, vectorization 6 0
07 Jul 2008 Zero Out Smalls To zero out the small elements whose absolute values are smaller than a given criterion. Author: Zhigang Xu small quantities, zeros, eps 4 4
Comments and Ratings by Zhigang Xu View all
Updated File Comments Rating
06 Sep 2009 ATAN2_SAFE To perform the same function as Matlab built-in function atan2 but safely guarded against erroneous Author: Zhigang Xu

ATAN2 is fine if you can be watchful each time for its small inputs, whereas, as has been said above, "To relieve you from the cleaning burden every time when you need to call ATAN2, ATAN2_safe automates the cleaning and the calling two steps for you."

05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu

Ah, the explanation to the above puzzle (i.e., NaN vs Double) lies in that whenever NaN is concatenated with other classes, it will be converted to zero first. Thus,

uint8(nan)

ans =

0

int32(nan)

ans =

0

[nan uint16([1 2])]

ans =

0 1 2

whereas
[nan double([1 2])]

ans =

NaN 1 2

A lesson to remember is that NaN is only a not-a-number within double class. It will become zero when it is converted to other classes.

05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu

This is a very thoughtful suggestion. Thanks! I did a quick experiment as follows, showing that NaN can only work with a double class to get right logical indices. I will implement your suggestion for next updating. Thanks again!

>> diff([nan [0 1]])~=0

ans =

1 1

>> diff([nan uint8([0 1])])~=0

ans =

0 1

04 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu

Matt,

Thanks for your comments and rating. Your suggestion can evidently make the codes more concise. However, using logical indexing is usually faster than FIND, as the Matlab Editor would advise. For this reason, I am hesitating to implement it for now. I tested your suggestion with a large input array (x=randi(999, 7e6,1)), and did not find any significant improvement in speed, although it did not go slower either. I am wondering if you can supply me your test script to show the significant difference in speed. I will be very happy to implement your suggestion after I understand why it can do so. Thanks!

Zhigang

04 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu

The updated version has been just up now (as 04-Sep-2009 11:09:21). So please feel free to download the new version. Thanks! --- Zhigang

Comments and Ratings on Zhigang Xu's Files View all
Updated File Comment by Comments Rating
03 Nov 2014 Read Global Topographic Data Two Matlab functions to extract the data from two global topographic data base, ETOPO2v2 and GEOBEC. Author: Zhigang Xu Amirhossein

12 Oct 2011 FDATENUM_etc A package offers much fast versions for datenum, datevec, and str2num. Author: Zhigang Xu Eran

I tested fstr2num with a large string (>1,000,000) of numbers such as: 11 44 44 11 33 13 33 22 11 44. Separated by a single space. str2num takes 3-4 seconds to convert them to numeric. fstr2num took less than a second, but it produced many more numbers than actually are, probably breaking some of the numbers to single numbers (1 2 3 4).

In short, it doesn't work well. hope you can fix it because the world needs it!

06 Sep 2009 ATAN2_SAFE To perform the same function as Matlab built-in function atan2 but safely guarded against erroneous Author: Zhigang Xu Zhigang Xu

ATAN2 is fine if you can be watchful each time for its small inputs, whereas, as has been said above, "To relieve you from the cleaning burden every time when you need to call ATAN2, ATAN2_safe automates the cleaning and the calling two steps for you."

05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu Zhigang Xu

Ah, the explanation to the above puzzle (i.e., NaN vs Double) lies in that whenever NaN is concatenated with other classes, it will be converted to zero first. Thus,

uint8(nan)

ans =

0

int32(nan)

ans =

0

[nan uint16([1 2])]

ans =

0 1 2

whereas
[nan double([1 2])]

ans =

NaN 1 2

A lesson to remember is that NaN is only a not-a-number within double class. It will become zero when it is converted to other classes.

05 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu Zhigang Xu

This is a very thoughtful suggestion. Thanks! I did a quick experiment as follows, showing that NaN can only work with a double class to get right logical indices. I will implement your suggestion for next updating. Thanks again!

>> diff([nan [0 1]])~=0

ans =

1 1

>> diff([nan uint8([0 1])])~=0

ans =

0 1

Contact us