Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How do I convert a grid 'surface' variable to distinct X, Y and Z variables?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a large output from an analysis of mine that is a 1001x89 double. The first row is the Y axis, and the first column is the X axis. The other values are the Z 'surface' values that populate the grid. Here's a simplified example:
nan 500 497 494 491 488 ...
240 0.01 0.01 0.01 0.01 0.01 ...
241 0.01 0.01 0.01 0.02 0.02 ...
242 0.01 0.01 0.02 0.02 0.02 ...
243 0.02 0.02 0.02 0.02 0.03 ...
244 0.03 0.03 0.03 0.03 0.04 ...
... ... ... ... ... ... ...
I'm after a loop that, for a given Z value in the grid (i.e. not anything in [1,:] or [:,1]), assigns that value to a new variable whilst also assigning the first value in the corresponding row and column to distinct variables as well.
Any help will be greatly appreciated.
0 件のコメント
回答 (1 件)
Rik
2019 年 2 月 7 日
If you restructure your data you can use tools like find, ismember, and ismembertol. That way you can use logical indexing to select only the data you need.
data=[NaN 500 497 494 491 488
240 0.01 0.01 0.01 0.01 0.01
241 0.01 0.01 0.01 0.02 0.02
242 0.01 0.01 0.02 0.02 0.02
243 0.02 0.02 0.02 0.02 0.03
244 0.03 0.03 0.03 0.03 0.04 ];
[X,Y]=ndgrid(data(2:end,1),data(1,2:end));
Z=data(2:end,2:end);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!