File Exchange

image thumbnail

.xyz file functions

version 1.0.0.0 (18.3 KB) by Chad Greene
Read .xyz files and make gridded datasets.

53 Downloads

Updated 06 Apr 2016

View License

Here are two functions:

xyzread reads text .xyz files into your Matlab workspace. This is written for GMT-generated .xyz files, but may work for other .xyz files as well.

xyz2grid converts the columnated data from a .xyz file into a gridded dataset that can be viewed with surf, pcolor, or imagesc. Note: this function does not interpolate! It simply reshapes the z values from a column of z data and puts them into a 2D matrix.

Cite As

Chad Greene (2021). .xyz file functions (https://www.mathworks.com/matlabcentral/fileexchange/56414-xyz-file-functions), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

yang chia chi

Thank you, you are the best!

Adhi Kusuma Negara

Thanks alot guys

John McDowell

Veronica Taurino

thank you!

Maga

Saved my life!!

Jingyu Gao

That's what I need, thanks a lot !~

John B.

Bo Zhao

It is so nice to have this function. Do you have any idea to develop it one step further so that it also accounts for 4D data i.e. xyz-V data for 3D volume presentation?

John

Chad Greene

masyrezaei: I haven't seen that error before, but it sounds like maybe your data are not of class double? Try this:

xyz2grid(double(x),double(y),double(z))

masyrezaei

Hi, it has error

Error using accumarray
FILLVALUE and output from the function 'sum' did not have the same class.

Error in xyz2grid (line 92)
Z = accumarray([yi xi],z(:),[],[],NaN);
can I handle it?
Thanks a lot

John Mitchell

Felipe Cruz

Francesco Cassano

Thank you very much! This functions are amazingly fast! You are my hero!

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

xyz file operations/html/