MATLAB: How to assemble coefficient matrix

matrix manipulationvectors

I am trying to assemble a N x N matrix for IC as shown above. I have vectors for ao(theta), c(theta), and thetal. I am trying to figure out how to assemble the IC matrix from these vectors using the equation above. From there I need to solve for the A vector values.

Best Answer

I'll assume you have a0, c, and theta as column vectors of corresponding elements and of length N.
IC = bsxfun(@plus,4*b./(a0.*c),(1./sin(theta))*(1:N)).*sin(theta*(1:N));
Of course it is much easier to write nested for loops:
IC = zeros(N);
for l = 1:N
for m = 1:N
IC(l,m) = (4*b/a(l)/c(l)+m/sin(theta(l)))*sin(m*theta(l));
end
end
Note: You ought to use something other than lowercase l for your index. It is too easily confused with the numeral 1.