MATLAB Answers

0

solving an equation in matlab

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

  0 件のコメント

サインイン to comment.

タグ

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!

  1 件のコメント

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 ??

サインイン to comment.


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.

  0 件のコメント

サインイン to comment.



Translated by