vec2grid

バージョン 1.3.0.1 (3.57 KB) 作成者: Kelly Kearney
Reshapes vector data to a grid
ダウンロード: 1.8K
更新 2021/9/23

vec2grid.m Documentation

View vec2grid on File Exchange

This is a simple utility to rearrange a list of data points into an ndgrid-style grid. It allows the original data points to be listed in any order, and allows for missing grid points (which become NaNs in the final grid).

Note: In order to support higher dimensional data, I opted to return data in ndgrid format rather than meshgrid format. This means output will often need to be transposed to be used with plotting functions like surf, pcolor, etc.

Syntax

[xg, yg] = vec2grid(x1, x2, ..., y);
[xg, yg] = vec2grid(xy);
[xg1, xg2, ... yg] = vec2grid(...);

Example

Let's assume we have a list of 2D data points, with a corresponding vector of z-data for each x-y point. The data points are stored in random order, and a few points are missing from the full grid.

[x,y] = ndgrid(1:4,1:5);
z = (1:numel(x))';

order = randperm(numel(x), numel(x)-3)';
x = x(order); y = y(order); z = z(order);

[x y z]
ans =

     1     3     9
     3     5    19
     4     3    12
     3     3    11
     2     2     6
     2     4    14
     4     5    20
     1     5    17
     2     3    10
     2     5    18
     4     2     8
     3     2     7
     3     4    15
     2     1     2
     1     1     1
     1     4    13
     3     1     3

We use vec2grid to return the data to a gridded format.

[xg,yg,zg] = vec2grid([x y z])
xg =

     1
     2
     3
     4


yg =

     1
     2
     3
     4
     5


zg =

     1   NaN     9    13    17
     2     6    10    14    18
     3     7    11    15    19
   NaN     8    12   NaN    20

引用

Kelly Kearney (2024). vec2grid (https://github.com/kakearney/vec2grid-pkg), GitHub. 取得済み .

MATLAB リリースの互換性
作成: R2007a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

vec2grid

GitHub の既定のブランチを使用するバージョンはダウンロードできません

バージョン 公開済み リリース ノート
1.3.0.1

linked GitHub readme

1.3.0.0

Corrected github-renaming of entry

1.2.0.0

Linked to GitHub repository

1.1.0.0

Added support for unlimited dimensions in input data.

1.0.0.0

この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。