Solution for an unknown variable

1 次查看(过去 30 天)
How do I solve this equation in matlab for alpha. all other values are known
Thanks in advance

采纳的回答

Alan Stevens
Alan Stevens 2020-6-8
Something like this (obviously, I've used dummy data):
% Initial guess
alpha0 = 1;
% Call function with fzero
alpha = fzero(@fn, alpha0);
function delta = fn(alpha)
% Data
N = 8;
PFA = 0.4;
S = 0;
for k = 0:N/2-1
S = nchoosek(N/2-1+k,k)*(2+alpha)^(-k) + S;
end
delta = 2*(2+alpha)^(-N/2)*S - PFA;
end

更多回答(2 个)

John D'Errico
John D'Errico 2020-6-8
There will be no analytical solution.
  1. Write a function that for any given values or N and alpha, if you knew alpha, it could compute the sum of that series. This part is trivial. Just pretend you knew the value of alpha, passing it into your function.
  2. Then for any given value of P_FA, use fzero to solve for the value of alpha that yields the desired value of P_FA.
The general form of your function will look like:
function P_FA = PFAfun(alpha,N)
% compute the series here
P_FA = stuff ;
end
You will need to fill in the stuff part. Easy code to write, and you need to do something, as this is your problem.
Now for any given values of N and P_FA, use fzero. The call will look like:
N_sol = ???
P_FA_sol = ???
alpha_start = ???
alphasol = fzero(@(alpha) PFAfun(alpha,N_sol) - P_FA_sol, alpha_start);
Here you need to fill in the values for N_sol and PFA_sol, since you know them. fzero will solve for a value of alpha, basedd ona starting value passed in for alpha_start. fzero will work better if you can provide TWO values as a vector in alpha_start, that you know contain the solution between them.

Walter Roberson
Walter Roberson 2020-6-8
N = 16; %must be even integer
PFA = rand() * 1000; %some value
syms alpha real
eqn = PFA == 2*(2+alpha)^(-N/2)*symsum(gamma(N-2-1+k+1)/gamma(k+1)/gamma(N/2-1+k-k+1)*(2+alpha)^(-k),k,0,N/2-1);
sol = vpasolve(eqn, alpha);
sol(imag(sol)==0)
I did find a case where the above was not enough, that some extra steps were needed to extract the answer. In part it involved compensating for the special possibility that alpha might be exactly -1
  2 个评论
Praanesh Sambath
Praanesh Sambath 2020-6-8
how do i input the value of 'k' in the equation as it is an iterative value

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by