how to add two loops

2 次查看(过去 30 天)
phoenix
phoenix 2017-9-10
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.

采纳的回答

Andrei Bobrov
Andrei Bobrov 2017-9-10
t = 1:k;
c = t.^2.*exp(1i*t) + t.*exp(-1i*t);
  1 个评论
Andrei Bobrov
Andrei Bobrov 2017-9-10
t = 1:k;
p=(2*t.^2+t+1)';
q=(2*t.^2+3*t+2)';
c = p.^2.*exp(1i*p) + q.*exp(-1i*q);

请先登录,再进行评论。

更多回答(1 个)

KSSV
KSSV 2017-9-10
p=1:1:k;
q=p;
x=p.^2*exp(j*p);
y=q.*exp(-j*q);
c=x+y;

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by