Matlab请问我用​符号计算计算出了一堆​公式,但我想用r去替​换公式中的某部分该怎​么做啊?比如。

比如f=((x - xi)^2 + (eta - y)^2)+1,我想用r替换((x - xi)^2 + (eta - y)^2)部分, 即变成f=r+1 请问这该怎么做啊 subs为啥不行 subexpr也不行

 Risposta accettata

0 voti

syms x xi eta y
f=((x - xi)^2 + (eta - y)^2)+1;
f=str2sym(replace(string(f),'(x - xi)^2 + (eta - y)^2','r'))
f =r + 1

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!