solving an equation in matlab
2 次查看(过去 30 天)
显示 更早的评论
Hi Dear Friends
i have below summation :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157487/image.png)
and also i always know value of 'm' , for example m=14 so after doing my job in other place i get RG :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157489/image.png)
so now i have RG without knowing Fi's , so i want to solve that equation but i really dont have a idea for this in matlab !!
please help
0 个评论
回答(2 个)
Cory Johnson
2016-10-29
This can be done with a for loop and symbolic variables.
It is good practice to assign contstants at the top of the script:
m =14
Fi = ??
If you are solving for p, create a symbolic variable for that:
syms p
Use i as the loop variable, then convert the summation to an equation in MATLAB:
for i = 1:14
R_G = F_i*p^(m-i)*(1-p)^i
end
The last steps are to solve the symbolic equation with respect to p, some condition, then, if you have enough information to get rid of variables, convert it to double.
solved_p = solve(R_G == value, p);
final_p = double(solved_p)
Hope that helps!
Roger Stafford
2016-10-30
I understand that you want to determine the values of Fi in your first RG expression, given m and the coefficients of an equivalent polynomial in p as in the second expression for RG. That is done by solving a set of m+1 linear equations in m+1 unknowns, namely the Fi values. Matlab can be used to accomplish this using the backslash operator. The necessary matrix of coefficients, M, in the linear equations can be constructed using the following code:
M = fliplr(eye(m+1));
M(m+1,:) = (-1).^(0:m);
for k = 2:m+1
M(1:m,k) = M(2:m+1,k-1)-M(1:m,k-1);
end
If C is a column vector of the polynomial coefficients of the given equivalent polynomial, C(1) + C(2)*p + C(3)*p^2 + ..., then solve the linear equations with:
F = M\C;
In your m = 14 example wherein the C values are:
C = [0;0;0;0;0;0;720;-4136;10741;-16356;15894;-10056;4034;-936;96]
you will find that the values of F turn out to be:
F = [1;14;89;340;869;1554;1949;1624;720;0;0;0;0;0;0]
That is, F0 = 1, F1 = 14, F2 = 89, F3 = 340, etc.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!