How to use command function?
Afficher commentaires plus anciens
Hi everyone,
I have to generate 15 matrices of dimensions 432x6. Instead of doing it manually, such as:
%create a matrix with the forecasted values of all currencies for the 1 predictor.
for i=1:6;
for t=1:432;
predictor_1(t,i)=k1_total(t,1+15*(i-1));
end;
end;
%create a matrix with the forecasted values of all currencies for the 2 predictor.
for i=1:6;
for t=1:432;
predictor_2(t,i)=k1_total(t,2+15*(i-1));
end;
end;
%create a matrix with the forecasted values of all currencies for the 3 predictor.
for i=1:6;
for t=1:432;
predictor_3(t,i)=k1_total(t,3+15*(i-1));
end;
end;
and so on. k1_total is a 432x90 matrix. How could I use the ''function'' command in order to avoid all these replications and look more coherent.
I 've tried the following:
for i=1:size(k1_total,2);
[predictor_i,xxx,xxx,xxx,xxx,xxx,xxx]=Create_predictors(...
k1_total(:,i));
results_ECON(i,:)=[predictor_i];
end;
and on the script, I use:
function [predictor_i,SR,weight_risky,cumulative_return,avg_turnover,Sortino,G]=...
Create_predictors(k1_total,ir_i,target_volatility,actual_risky_return_i,ir_us_lag,k1_uk)
for i=1:6;
for t=432;
predictor_k_econ(t,i)=k1_total(t,1+15*(i-1));
end;
end;
But I get an error of mismatching dimensions. I would appreciate any help. Thanks in advance.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Linear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!