symbolic calculation - subs does not work after diff

In the following code I create a symbolc expression. I want to differentiate it and after that I want to evaluate it at specific datapoints. The evaluation works before the diff command but not afterwards. In other examples this works well but not in the one shown below. Any ideas?
syms x
A=1;
B=2;
D=1;
C=3;
E=A+(B*C^2)./(B^2-x.^2-1i.*C.*x);
n=sqrt((sqrt(real(E).^2+imag(E).^2)+real(E))./2);
y=10:1:300;
nN=subs(n,x,y);
plot(y,nN)
dn=diff(n);
dnN=subs(dn,x,y)
plot(y,dnN)
Thanks, Dirk

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 19 日

0 投票

syms x real
A=1;
B=2;
D=1;
C=3;
E=A+(B*C^2)./(B^2-x.^2-1i.*C.*x);
n=sqrt((sqrt(real(E).^2+imag(E).^2)+real(E))./2);
y=10:1:300;
nN=subs(n,x,y);
plot(y,nN)
dn=diff(n);
dnN=subs(dn,x,y)
plot(y,dnN)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2011 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by