fitlm with sequential variable names
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to run multiple regressions using a for loop. This is my code:
(N is the number of columns in the matrices, each column represents one of the 24 hours. Each matrix is a different variable.)
for i = 1:N
table_hourly = table( First_matrix(:,i), Second_matrix(:,i), Third_matrix(:,i),'VariableNames', ...
{sprintf('Variable1_Hour%d',i) sprintf('Variable2_Hour%d',i) sprintf('Variable3_Hour%d',i)});
a = sprintf('Variable1_Hour%d',i);
b = sprintf('Variable2_Hour%d',i);
c = sprintf('Variable3_Hour%d',i);
fitlm(table_hourly, 'a ~ b + c', 'Intercept',0,'Robust',1)
end
With this code, I can correctly create a table (table_hourly) for each different hour, with the right column headers. However, when it gets to the regression, fitlm fails to recognise the variable names.
How can I solve this problem?
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!