简体   繁体   English

如何从CSV文件导入粗糙的2D表面,内插和导出精致的CSV文件OCTAVE

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

I am extremely new to OCTAVE. 我对OCTAVE非常陌生。 Would appreciated any help. 将不胜感激。

I have a CSV file with a 2-D array of z-value points. 我有一个带有z值点的二维数组的CSV文件。 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)) 这些点沿X和Y轴均匀分布,并且对应于存储z值的行/列。(即,第一列,第一行,z = 4对应--- >>(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? 如何导入此z值的csv文件并将其用作二维网格上的点? Then, how can I interpolate these values on a finer 2-D grid and then export the refined 2-D array? 然后,如何在更精细的2D网格上插值这些值,然后导出精确的2D数组?

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). 我的网格是X&Y从0到9且步长为1的正方形,我想使步长为0.1(100个数据点到10000个数据点)。

I know this is a simple matter of using griddata, meshgrid, linspace, or interp2...but I do not how to do accomplish it. 我知道这是使用griddata,meshgrid,linspace或interp2的简单问题,但是我不知道如何做到这一点。

PLEASE anyone can you help me 请任何人可以帮助我

I've created a file derek.csv: 我创建了一个文件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: 现在,您可以使用dlmread从GNU Octave加载它,创建新的网格(例如间距为0.5的网格)并调用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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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