I am trying to a series generated from complex function but it gives to me an error.

조회 수: 1 (최근 30일)
clear;
clc;
syms k
Delta=0;
chi=0;
theta=0;
alpha=5;
phi=0;
bn=exp(-0.5*alpha^2)*(alpha^k)/sqrt(gamma(k+1));
bn1=exp(-0.5*alpha^2)*(alpha^(k+1))/sqrt(gamma(k+2));
t = 0:pi/100:2*pi;
Gamma=chi*k^2-0.5*Delta;
Wn=0.5*Delta-chi*k;
mu=sqrt((0.5*Delta-chi*k)+k+1);
An=exp(-1i*Gamma*t)*(bn*cos(theta/2)*(cos(mu*t)-1i*Wn*sin(mu*t)/mu)-1i*bn1*sqrt(k+1)*sin(theta/2)*exp(-1i*phi)*sin(mu*t)/mu);
zz=real(An)^2+2*imag(An);
y1 = symsum(zz,k, 0, 20);
plot(t,y1,'r','Color',[0.5 0 0.8])
Error using mupadmex
Error in MuPAD command: The dimensions do not match. [(Dom::Matrix(Dom::ExpressionField()))::_mult2]
Error in sym/privBinaryOp (line 820)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 216)
X = privBinaryOp(A, B, 'symobj::mtimes');
Error in Untitled222 (line 17)
An=exp(-1i*Gamma*t)*(bn*cos(theta/2)*(cos(mu*t)-1i*Wn*sin(mu*t)/mu)-1i*bn1*sqrt(k+1)*sin(theta/2)*exp(-1i*phi)*sin(mu*t)/mu);
>>

답변 (1개)

VBBV
VBBV 2022년 5월 1일
편집: VBBV 2022년 5월 1일
clear;
clc;
syms k
Delta=0;
chi=0;
theta=0;
alpha=5;
phi=0;
bn=exp(-0.5*alpha^2)*(alpha^k)/sqrt(gamma(k+1));
bn1=exp(-0.5*alpha^2)*(alpha^(k+1))/sqrt(gamma(k+2));
t = 0:pi/100:2*pi;
Gamma=chi*k^2-0.5*Delta;
Wn=0.5*Delta-chi*k;
mu=sqrt((0.5*Delta-chi*k)+k+1);
An=exp(-1i*Gamma*t).*(bn*cos(theta/2).*(cos(mu*t)-1i*Wn.*sin(mu*t)./mu)-1i*bn1*sqrt(k+1)*sin(theta/2)*exp(-1i*phi).*sin(mu*t)./mu);
zz=real(An).^2+2*imag(An);
y1 = symsum(zz,k, 0, 20);
plot(t,y1,'r','Color',[0.5 0 0.8])
  댓글 수: 1
VBBV
VBBV 2022년 5월 1일
편집: VBBV 2022년 5월 1일
Matlab uses elementwise operator ./ .* for multiplying or dividing one or more multidimensonal vectors

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by