I am trying to write data from fitlm model to excel and write a column vector of the name of variables into my excel table
Ältere Kommentare anzeigen
Hi,
Here is my code:
clear all
X = xlsread('example.xlsx', 1, 'A2:A857'); %get data from column in excel
Y = xlsread('example.xlsx', 1, 'B2:B857');%get data from column in excel
md1 = fitlm(X, Y); %run correlation test between different variables
T = table([''; 'Intercept'; 'Y']); %create column vector of compared variable names
writetable(T, 'example.xlsx', 'Sheet', 2, 'Range', 'A1'); %add names to spreadsheet
writetable(md1.Coefficients, 'example.xlsx', 'Sheet', 2, 'Range', 'B1'); %add results to spreadsheet
writetable(md1.Rsquared.Ordinary, 'example.xlsx', 'Sheet', 2, 'Range', 'G1'); %add results to spreadsheet
writetable(md1.Rsquared.Adjusted, 'example.xlsx', 'Sheet', 2, 'Range', 'G1'); %add results to spreadsheet
I have two problems:
1. I am returned the following error when trying to create a column vector to add to my spreadsheet's table:
Error using (line 8) Dimensions of matrices being concatenated are not consistent.
2. My second error is when using dot notation to collect the data from md1:
|Undefined function 'write' for input arguments of type 'double'.
Error in writetable (line 121) write(a,filename,varargin{:})
Error in (line 13) writetable(md1.Rsquared.Ordinary, 'example.xlsx', 'Sheet', 2, 'Range', 'F1'); %add results to spreadsheet |
Could you help me solve these problems, please?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!