How to replace equations in symbolic function
显示 更早的评论
Good Morning,
Please I have a function F = 3*a*b
Therefore how can i change (a*b) with a variable 'x' to obtain F = 3*x
Think you.
采纳的回答
By using subs function:
syms a b x
F=3*a*b;
Fnew=subs(F,{a,b},{x,1})
9 个评论
Think you very much Bridman but don't work with my problem
beacause my problem that I have a function F = A*(q1^2) + B*(q2^2) + C*(q1*q2) + D*(q2*q3);
And I want change : (q1^2) with t1 / (q2^2) with t2 / (q1*q2) with t12 / (q2*q3) with t23
to obtain F = A*t1 + B*t2 + C*t12 + D*t23
Think you.
That 1 stands for replacing with b.
Your problem should be solved by the following code:
syms A B C D q1 q2 q3 t1 t2 t12 t23
F=A*q1^2+B*q2^2+C*q1*q2+D*q2*q3
%the following line does the trick
Fnew=subs(F,{q1^2,q2^2,q1*q2,q2*q3},{t1 t2 t12 t23})
I already did that but unfortunately does not work

Just t1 and t2 changes.
Which version of MATLAB are you using? I am using 2019b and it is working well for me.
I work with matlab R2011a
Isthere any other method without using the maple function because i have this problem
??? Error using ==> maple at 54
The MAPLE command is not available.
Is there any chance you can use a newer release of MATLAB?
i will install it
Think you
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
