sum of a product with i differnt to j
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    MichMichel
 el 7 de Feb. de 2019
  
    
    
    
    
    Comentada: Matt J
      
      
 el 7 de Feb. de 2019
            Hi All,
I want to calculate a sum of a product as following:

I think my problem is quite relative to this topic: Double sum of a product, but in my case I have j ~= i.
I think something like that should work:
t = 1:100;
n = 10;
a = randn(n,1);
P = [];
for i = 1:n
    F = [];
    for j = 1:n
        if j~=i
            f = (a(j)-a(i))^n*t;
            F = [F,f'];
        end
    end
    p = prod(F,2);
    P = [P,p];
end
res = sum(P,2);
But I feel that this solution is not good and something easier should exist?
Thanks a lot,
M.
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements 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!

