Merge vector to matrix

9 ビュー (過去 30 日間)
Idan Cohen
Idan Cohen 2020 年 4 月 22 日
コメント済み: dpb 2020 年 4 月 22 日
Hi all,
I have three vectors - X and Y. Vector three (Z) is the solution for X and Y (see picture attached). I want to convert these three vectors to a matrix that I can plot 3-D surfc. X and Y are the parameters and Z is the solution in the matrix.
How can I do that?
Thanks.
Idan

回答 (1 件)

dpb
dpb 2020 年 4 月 22 日
In what form do you have the data to start with? If it's a file with the content of the document shown, then just read the file into an array or table to start with instead of creating multiple variables ("It's the MATLAB way!")
tZYZ=readtable('yourfile.dat');
will leave you with a table with variable names of X, Y, Z[V] and you can then reshape() by the grid size to match the necessary meshgrid interleaving...let's see what that looks like---eww! that's a bugger! The grid spacing is not regular along the X direction for the steps of Y; that doesn't fit the rules for surfc of a regular x/y grid.
I think you'll have to either be able to build a regular grid that bounds the range of X,Y in the data and infill what you have for locations with NaN for the missing Z values or use one of surface interpolating functions for scattered surface and see if can interpolate to the regular mesh.
Sorry I don't have the time to try to dig further right now; maybe somebody else will come along soon for the rest...
  2 件のコメント
Idan Cohen
Idan Cohen 2020 年 4 月 22 日
編集済み: Idan Cohen 2020 年 4 月 22 日
Thank you for trying.
I get the data exactly the way you see it on the file and I need to do a lot of work on it. The plot is nothing compare to the work I need to do. I know there is a add-ons app to excel that can do that (monthly cost). I prefer to use one software.
I thought maybe there is a function that do that the same as the add-ons app for excel.
Thanks anyway.
dpb
dpb 2020 年 4 月 22 日
Well processing the data shouldn't be difficult at all as long as you don't need the regular mesh but just operate on either all or pieces of the data vectors.
I'm certain it's doable; I just have other fires to put out right now so don't have much time to put in to anything can't just answer otomh, sorry.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by