Solution for an unknown variable
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Praanesh Sambath
le 8 Juin 2020
Commenté : Walter Roberson
le 8 Juin 2020
How do I solve this equation in matlab for alpha. all other values are known
Thanks in advance
0 commentaires
Réponse acceptée
Alan Stevens
le 8 Juin 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
0 commentaires
Plus de réponses (2)
John D'Errico
le 8 Juin 2020
There will be no analytical solution.
- 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.
- 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.
0 commentaires
Walter Roberson
le 8 Juin 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 commentaires
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!