How to extract the values of x and y from this matlab regression models?

4 ビュー (過去 30 日間)
Ahmed Elbeltagi
Ahmed Elbeltagi 2020 年 8 月 29 日
コメント済み: Adam Danz 2020 年 8 月 31 日
I have executed the matlab regression modeling (see the attached screenshot) but i want to extract the data of x,y into excel sheet to use it in drawing other plots.
can any one help me?
Regards
Ahmed
  4 件のコメント
Ahmed Elbeltagi
Ahmed Elbeltagi 2020 年 8 月 30 日
Thanks a lot for your help Mr. Adam Danz Your help
I have applied your steps and reached to this point as shown in attached screenshot.
How to extract values of Y{1,1} and Y{2,1} into excel sheet. OR, How to extract the values of Y into excel sheet file.
Waiting for your kind reply.
Regards
Adam Danz
Adam Danz 2020 年 8 月 30 日
編集済み: Adam Danz 2020 年 8 月 31 日
Glad it's working out. I copied the comment to the answers section and addressed your additional questions.

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

採用された回答

Adam Danz
Adam Danz 2020 年 8 月 30 日
編集済み: Adam Danz 2020 年 8 月 30 日
Step 1) Access the (x,y) coordinates that are plotted within the Regression Learner App. If you can't extract the data directly from "export model", you could extract them from the app's figure.
  1. Get the handle to the app's axes. Here are two ways to do that.
  2. Once you have the handle, let's call is RLax, you can get the (x,y) coordinates of each plotted object using two lines below.
X = get(RLax.Children, 'XData');
Y = get(RLax.Children, 'YData');
X and Y will be cell arrays, one element for each line object, containing 1*n vectors.
Step 2) Convert the cell arrays to matricies. If each vector within the cell array is the same length, convert the cell array to a matrix using,
m = cell2mat(Y')';
If the vectors contain a different number of elements, you'll need to pad the shorter vectors with NaN values using,
maxNumCol = max(cellfun(@numel, Y)); % max length
m = cell2mat(cellfun(@(c){padarray(c,[0,maxNumCol-size(c,2)],NaN,'Post')},Y))';
Both versions result in an m*n matrix of m observations and n variables.
Step 3) Write the data to an excel file. If you only want to write the matrix,
writematrix(m, 'myData.xlsx')
If you want to include column headers Y1, Y2, ..., Yn
T = array2table(m, 'VariableNames', compose('Y%d',1:size(mPad,2)));
writetable(T, 'myData.xlsx')
For more info on writing to excel:
  2 件のコメント
Ahmed Elbeltagi
Ahmed Elbeltagi 2020 年 8 月 31 日
Done Mr. Adam Danz
Thanks a lot for your help
Many thanks again.
Cheers
Adam Danz
Adam Danz 2020 年 8 月 31 日
Glad I could help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGaussian Process Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by