help for vectorization coding for multiplication and addition matrixs
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    reshdev
 el 6 de Sept. de 2014
  
Hello,
I have two separate codes.
Use of for loops for following codes making them too heavy , so they are taking too long for bigger size matrix's. can anyone please help me to write both in vectorized form.
Thanks
CODE 1---
 Ft= zeros(n,n);
 for row=1:na
     for col =1:nv
        tn(row,col)= st(row,col)*y(row,col);if y(row,col)>0
        tn(row,col) =  tn(row,col)+ff(row,col);
      end
    end
end
0 comentarios
Respuesta aceptada
  Roger Stafford
      
      
 el 6 de Sept. de 2014
        
      Editada: Roger Stafford
      
      
 el 6 de Sept. de 2014
  
      Try this:
   Fn = cost.*W+(W>0).*FC;
and
   W = sum(reshape(outp(:,1:n*dr,u),[],n,dr),3);
(I assume u is a scalar index here.)
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

