Asked by Nilanjan Roy
on 29 May 2012

Hi I have a 100x100 matrix, A. I am doing the following:

q=0:0.1:50;sym k; for j=1:length(q)

B1(j)=sum(exp(q(j)*A(k,1)), k=1..100); end for j=1:length(q)

B2(j)=sum(exp(q(j)*A(k,2)), k=1..100); end .................................. .................................. for j=1:length(q)

B100(j)=sum(exp(q(j)*A(k,100)), k=1..100); end

The problem is perhaps with the command but I tried with both sum/symsum and some other variations. But always matlab gives one or the other error.

It would be very helpful if someone could suggest some "correct" command. Thanks a ton.

*No products are associated with this question.*

Answer by Geoff
on 29 May 2012

Accepted answer

I would expect this to work:

B = zeros(length(q), size(A,2)); for j = 1:length(q) B(j,:) = sum( exp(q(j)*A) ); end

Nilanjan Roy
on 29 May 2012

Geoff
on 29 May 2012

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 1 Comment

## Walter Roberson (view profile)

Direct link to this comment:http://fr.mathworks.com/matlabcentral/answers/39677#comment_82067

http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F