How can I use MATLAB to plot and sum values using vectors and matrices?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 6K views
kobjob
Messages
6
Reaction score
0
Hi everyone,

Could someone please tell me how to get MATLAB to do the following seemingly simple task..

j=1:3;
k1=1:3;
m=eye(3)

plot(j,symsum((p8+k1(j)).*m(p8,j),p8,1,3))

or,

k=1:3;
plot(j,sum((k+k1(j)).*m(k,j)))

Thanks for any suggestions,
Kate
 
Physics news on Phys.org
It would probably help if you wrote the question and what you are trying to do.
 
Well k1 is a vector with entries 1 to 3, k1=(1 2 3).
m is the 3 x 3 identity matrix.

For each j, I want to do the sum from k= 1 to 3
sum((k+k1(j)).*m(k,j)) = (1+k1(j))*m(1,j) + (2+k1(j))*m(2,j) + (3+k1(j))*m(3,j)

Then I want to plot the values of the sum for each j.