Looping for calculate parameter
    4 views (last 30 days)
  
       Show older comments
    
    Guilherme Lopes de Campos
 on 18 Feb 2019
  
    
    
    
    
    Commented: Guilherme Lopes de Campos
 on 18 Feb 2019
            Hi MATLAB community, 
I am trying create a structure to calculate a parameter,
For made this, I would to calculate de a(1)*F(:,1)+a(2)*F(:,2)+a3*F(:,3)......until a(i)*F(i), respectily until that total number of parameters ((i=number of factors), 4 in the case).  I have a  doubt if I use for or while for this structure.
Could you help me?
Thank you very much
Guilherme Lopes de Campos 
correlation=corrcoef(X); % size X(324,19)
eigvalue = eig(correlation); 
factor = nnz(eigvalue>=1);% number of factor ( 4 in the case)
nonfactor = nnz(eigvalue<1);
sumeigvalue = sum(eigvalue);
eigvalue = eig(correlation);
[n,j] = size(eigvalue)
for i = 1:n       
    if  eigvalue(i)>=1;        
        a(i)= eigvalue(i);     %obtained the vector of a(i)
    end
end
a = sort(a,'descend')
for i=1:factor
    parameter = a(i)*F(:,i);   % F is a matrix (324,4) 
end
Guilherme 
0 Comments
Accepted Answer
  Jan
      
      
 on 18 Feb 2019
        With a FOR loop:
S = 0;
for k = 1:numel(a)
    S = S + a(k) * F(:, k);
end
Or without a loop:
S = F(:, 1:numel(a)) * a(:);
More Answers (0)
See Also
Categories
				Find more on Get Started with MATLAB in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!