Info

This question is closed. Reopen it to edit or answer.

Hi, I need to save result in an excel but with a for bucle, in my case a and mdl, please help

1 view (last 30 days)
Hi, i am new on matlab, and I need to save te result of a and mdl to an excel could someone help me?
clc X0 = xlsread('Datos','Pols');
for i=1:3 disp('---------------------Nueva Regresión-----------------') X=X0; f=ones(58); Y=f(:,1); beta = X(i:i+57,:)\Y; mdl = LinearModel.fit(X(i:i+57,:),Y,'Intercept',false); beta/sum(beta);
while (length(beta)-sum(beta>=0))>0; f=ones(58); Y=f(:,1); X(:,find((beta/sum(beta))<0)) = []; beta = X(i:i+57,:)\Y; mdl = LinearModel.fit(X(i:i+57,:),Y,'Intercept',false); beta/sum(beta); end disp('Los pesos del portafolio son : ') a=beta/sum(beta) disp('El análisis de las variables es el siguiente:') mdl = LinearModel.fit(X(i:i+57,:),Y,'Intercept',false) end end
that is my code, if you could help me, it would be great
  1 Comment
Geoff Hayes
Geoff Hayes on 15 Oct 2014
Sebastián - please format the above code so that it is readable. Highlight the code portions and press the {} Code button. As for writing a and mdl to file, check out xlswrite and in particular the examples.

Answers (0)

Community Treasure Hunt

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

Start Hunting!