solving an equation in matlab

조회 수: 4 (최근 30일)
Alireza Lashgary
Alireza Lashgary 2016년 10월 29일
편집: Walter Roberson 2016년 10월 30일
Hi Dear Friends
i have below summation :
and also i always know value of 'm' , for example m=14 so after doing my job in other place i get RG :
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

답변 (2개)

Cory Johnson
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!
  댓글 수: 1
Alireza Lashgary
Alireza Lashgary 2016년 10월 29일
no i dont want to solve for p ! p is variable and it other side of equation it remains as p ... i want to find F_i's ??

댓글을 달려면 로그인하십시오.


Roger Stafford
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.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by