필터 지우기
필터 지우기

Solution for an unknown variable

조회 수: 4 (최근 30일)
Praanesh Sambath
Praanesh Sambath 2020년 6월 8일
댓글: Walter Roberson 2020년 6월 8일
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
Walter Roberson
Walter Roberson 2020년 6월 8일
syms k
The symsum() takes care of the rest.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by