MATLAB: How to add two loops

loops

how to write this in matlab. c=x+y; where x=p^2*e^j*p and y=q*e^(-j*q); p,q ranges from 1:1:k.

Best Answer

t = 1:k;
c = t.^2.*exp(1i*t) + t.*exp(-1i*t);