![]() |
我们如何在MATLAB版本5.3.1中存储符号表达式的某些特定系数?
你好朋友,我想找出以下问题:假设我们有这样的表达,
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 ,最后将此值放在表达式的其余部分中,如何在不剪切和粘贴的情况下做到这一点。 [B]回答:[/B] 我不知道MATLAB版本5.3.1提供了哪些符号功能,但是您可以使用当前[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/"]Symbolic Math Toolbox中的[/URL] [URL="http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/coeffs.html"]COEFFS[/URL] , [URL="http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/subs.html"]SUBS[/URL]和[URL="http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/solve.html"]SOLVE[/URL]函数来解决您的问题: >> 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的值)。 [url=https://stackoverflow.com/questions/3305897]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 14:17。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.