Pcolor extract values of X,Y and C into one table?

1 回表示 (過去 30 日間)
Rebecca Furlong
Rebecca Furlong 2021 年 1 月 18 日
回答済み: Hrishikesh Borate 2021 年 2 月 2 日
Hi, I have created a pcolor plot based on values that I have, I would like to extract the X, Y and C values into one table (preferably .txt or .csv), as I need to be able to open this data in GIS. I have been able to extract the data using the following code, but the problem I have is that it is three separate tables, is it possible to extract all three into one table?
hfig = openfig('myfig');
H = findobj(hfig,'type','surface');
x_data = get(H,'xdata');
y_data = get(H,'ydata');
c_data = get(H,'cdata');

回答 (1 件)

Hrishikesh Borate
Hrishikesh Borate 2021 年 2 月 2 日
Hi,
It is my understanding that you want to combine the data stored in variables x_data, y_data, c_data into a table and write that table to a .txt file.
Following is the code for the same.
X = [1 2 3; 1 2 3; 1 2 3];
Y = X';
C = [3 4 5; 1 2 5; 5 5 5];
hfig = pcolor(X,Y,C)
h = findobj(hfig,'type','surface');
x_data = get(h,'xdata');
y_data = get(h,'ydata');
c_data = get(h,'cdata');
T = table(x_data(:), y_data(:), c_data(:), 'VariableNames',{'X Data', 'Y Data', 'C Data'});
writetable(T,'MyFile.txt');
For more information, refer writetable.

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by