function and indexing erros
    4 views (last 30 days)
  
       Show older comments
    
Hello a newest asking for help.
I have a function to calculate in a loop a variable.
function Ls= WeLatente(WeSolFin,Lc,Ds)
   Ls=zeros(1,6);
   Ls=0; 
   k=6;
   for k=1:k
      Ls(k)=Ls(k)+WeSolFin(k)'*Lc*Ds;
   end
and I get 2 errors messages :
    Not enough input arguments.  
and 
    Error in WeLatente (line 6)
      Ls(k)=Ls(k)+WeSolFin(k)'*Lc*Ds;
Any help i'll appreciate.
4 Comments
  Walter Roberson
      
      
 on 22 Dec 2018
				It is not enough that WeSolFin, Lc, and Ds exist in .mat files. You have to load them into memory and you have to pass them in when you call WeLatente
Note that
   k=6;
   for k=1:k
is confusing. It would be recommended to use a different variable name for the upper bound than is used for the loop index.
Accepted Answer
  madhan ravi
      
      
 on 22 Dec 2018
        
      Edited: madhan ravi
      
      
 on 22 Dec 2018
  
      EDITED
Addendum to sir Image Analyst and sir Walter's comments:  
upload your .mat file
load matlab.mat % load your .mat file  
Ls= WeLatente(WeSolFin{:,:},Lc,Ds) % function call
function Ls= WeLatente(WeSolFin,Lc,Ds)  % function definition
   Ls=zeros(1,6);
   k=6;
   for i=2:k
      Ls(i)=Ls(i-1)+WeSolFin(k)'*Lc*Ds;
   end
end
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!