Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
你好朋友,我想找出以下问题:假设我们有这样的表达,
syms tk A0 r1=(-1+k-3/4*k*A0^2)*sin(t)+1/4*k*A0^2*sin(3*t)+A0*sin(5*t); 我们想要删除sin(t)的系数并将其求解为A0 ,最后将此值放在表达式的其余部分中,如何在不剪切和粘贴的情况下做到这一点。 回答: 我不知道MATLAB版本5.3.1提供了哪些符号功能,但是您可以使用当前Symbolic Math Toolbox中的 COEFFS , SUBS和SOLVE函数来解决您的问题: >> eqCoeffs = coeffs(r1,sin(t)); %# Get coefficients for polynomial in sin(t) >> b = eqCoeffs(2); %# Second coefficient is what you want >> bValue = 1; %# The value to set the coefficient equal to >> newA0 = solve(subs('b = bValue'),A0) %# Solve for A0 newA0 = -(2*3^(1/2)*(k - 2)^(1/2))/(3*k^(1/2)) %# Note there are two values since (2*3^(1/2)*(k - 2)^(1/2))/(3*k^(1/2)) %# A0 is squared in the equation >> r2 = subs(r1,A0,newA0) %# Substitute the new A0 values into r1 r2 = sin(t) + (sin(3*t)*(k - 2))/3 - (2*3^(1/2)*sin(5*t)*(k - 2)^(1/2))/(3*k^(1/2)) sin(t) + (sin(3*t)*(k - 2))/3 + (2*3^(1/2)*sin(5*t)*(k - 2)^(1/2))/(3*k^(1/2)) 请注意, r2的两个方程式中的sin(t)系数等于1(我用于bValue的值)。 更多&回答... |
![]() |
![]() |