syms t k 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
&最后把这个值放到表达式的其余部分。我们怎样才能完成它而不需要剪切和粘贴。
答案 0 :(得分:0)
我不知道MATLAB版本5.3.1有哪些符号功能可用,但您可以使用当前的COEFFS,SUBS和SOLVE函数来解决问题Symbolic Math Toolbox:
>> 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))
请注意,sin(t)
这两个方程中r2
的系数等于1(我用于bValue
的值)。