fitlm with sequential variable names
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Linear Regression dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!