How to find different values of a function for i = 0 to 10

1 view (last 30 days)
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?

Accepted Answer

KSSV
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
R shah
R shah on 23 Jun 2016
Edited: Walter Roberson on 23 Jun 2016
hey i've made this change and getting the desired results, kindly check;
clc; clear all
a = 1/2 ;
b = 1/2 ;
for k = 0:4
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));
display(hk)
end
Walter Roberson
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.

Sign in to comment.

More Answers (1)

Andrei Bobrov
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
R shah
R shah on 23 Jun 2016
Edited: Walter Roberson on 23 Jun 2016
u've given a good clue but i've added a for loop in this code which is;
clc; clear all
a = 1/2 ;
b = 1/2 ;
for k = 0: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));
display(hk)
end
thanks a lot for your help

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!