Solution for an unknown variable

1 view (last 30 days)
How do I solve this equation in matlab for alpha. all other values are known
Thanks in advance

Accepted Answer

Alan Stevens
Alan Stevens on 8 Jun 2020
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

More Answers (2)

John D'Errico
John D'Errico on 8 Jun 2020
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 on 8 Jun 2020
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 Comments
Praanesh Sambath
Praanesh Sambath on 8 Jun 2020
how do i input the value of 'k' in the equation as it is an iterative value
Walter Roberson
Walter Roberson on 8 Jun 2020
syms k
The symsum() takes care of the rest.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!