How to sum the product between a matrix and 2 vectors
I need to solve a system of differential equation written as:
For each equation I should solve a summation like:
where K_Br is a matrix previously calculated and n is a vector as the solution of the differential equation system.
For example, for i=3:
I wrote the system of differential equation as:
function ndot = System_ni (t,n)
ndot = zeros(M,1);
ndot(1) = -n(1)*sum(K_Br(1,1:M)*n(1:M));
for i = 2:M
ndot(i) = 1/2*sum(K_Br(1:i-1,i-1:1)*n(i-1:1)*n(1:i-1))-n(i)*sum(K_Br(i,1:M)*n(1:M));
end
end
but summation seems not to work.
Thank you in advance for any help.I need to solve a system of differential equation written as:
For each equation I should solve a summation like:
where K_Br is a matrix previously calculated and n is a vector as the solution of the differential equation system.
For example, for i=3:
I wrote the system of differential equation as:
function ndot = System_ni (t,n)
ndot = zeros(M,1);
ndot(1) = -n(1)*sum(K_Br(1,1:M)*n(1:M));
for i = 2:M
ndot(i) = 1/2*sum(K_Br(1:i-1,i-1:1)*n(i-1:1)*n(1:i-1))-n(i)*sum(K_Br(i,1:M)*n(1:M));
end
end
but summation seems not to work.
Thank you in advance for any help. I need to solve a system of differential equation written as:
For each equation I should solve a summation like:
where K_Br is a matrix previously calculated and n is a vector as the solution of the differential equation system.
For example, for i=3:
I wrote the system of differential equation as:
function ndot = System_ni (t,n)
ndot = zeros(M,1);
ndot(1) = -n(1)*sum(K_Br(1,1:M)*n(1:M));
for i = 2:M
ndot(i) = 1/2*sum(K_Br(1:i-1,i-1:1)*n(i-1:1)*n(1:i-1))-n(i)*sum(K_Br(i,1:M)*n(1:M));
end
end
but summation seems not to work.
Thank you in advance for any help. summation, product, matrix vector product, differential equations MATLAB Answers — New Questions