简体   繁体   中英

How to import coarse 2D surface from CSV file, interpolate and export refined CSV file OCTAVE

I am extremely new to OCTAVE. Would appreciated any help.

I have a CSV file with a 2-D array of z-value points. The points are evenly spaced along X and Y axes, and correspond to the row/column the z-value is stored in. (ie first column, first row, z=4 corresponds to --->> (0,0,4))

QUESTION:

How can I import this csv file of z-values and use it as my points on a 2-D grid? Then, how can I interpolate these values on a finer 2-D grid and then export the refined 2-D array?

My grid is a square with X&Y from 0 to 9 with step of 1, I want to make the step 0.1 (100 data points to 10000 data points).

I know this is a simple matter of using griddata, meshgrid, linspace, or interp2...but I do not how to do accomplish it.

PLEASE anyone can you help me

I've created a file derek.csv:

8 4 9
4 5 6
8 9 3
5 3 4

Now you can load it from GNU Octave with dlmread, create the new grid (example with 0.5 spacing) and call interp2:

Z = dlmread ("derek.csv", " ");
[XX, YY] = meshgrid (1:0.5:columns(Z), 1:0.5:rows(Z));
newZ = interp2 (Z, XX, YY)

which gives

 8.0000   6.0000   4.0000   6.5000   9.0000
 6.0000   5.2500   4.5000   6.0000   7.5000
 4.0000   4.5000   5.0000   5.5000   6.0000
 6.0000   6.5000   7.0000   5.7500   4.5000
 8.0000   8.5000   9.0000   6.0000   3.0000
 6.5000   6.2500   6.0000   4.7500   3.5000
 5.0000   4.0000   3.0000   3.5000   4.0000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM