How to find different values of a function for i = 0 to 10
1 view (last 30 days)
Show older comments
i want to calculate different values of h_k for k = 0 to 10 and alpha = beta = 1/2 where
how to solve this in MATLAB?
0 Comments
Accepted Answer
KSSV
on 22 Jun 2016
It is a Home Work problem. As gamma function is involved, I am helping you out.
clc; clear all
a = 1/2 ;
b = 1/2 ;
hk = zeros(10,1) ;
for k = 1:10
hk(k) = 2^(a+b+1)*gamma(k+a+1)*gamma(k+b+1)/((2*k+a+b+1)*gamma(k+1)*gamma(k+a+b+1));
end
4 Comments
Walter Roberson
on 23 Jun 2016
If you want to be able to compute with them later instead of just displaying them, then assign into an array like was shown,
a = 1/2 ;
b = 1/2 ;
for k = 0:4
hk(k+1) = 2^(a+b+1)*gamma(k+a+1)*gamma(k+b+1)/((2*k+a+b+1)*gamma(k+1)*gamma(k+a+b+1));
display(hk(k+1))
end
The k+1 instead of k by itself is to allow you to start from 0, as MATLAB does not allow you to index at location 0.
More Answers (1)
Andrei Bobrov
on 22 Jun 2016
a = 1/2 ;
b = 1/2 ;
k = 1:10;
hk = 2^(a+b+1)*gamma(k+a+1).*gamma(k+b+1)./((2*k+a+b+1).*gamma(k+1).*gamma(k+a+b+1));
1 Comment
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!