MATLAB function which take value of n and x as argument and display the sum of the following series
Posted in matlab
No comments
Thursday, July 31, 2014 By Anonymous
Write
a MATLAB function which take value of n and
x as argument and display the
sum of the following series. i.e. sum of the factorial of odd series multiply
with x where power of x is square of corresponding number. E.g. if n = 5 and x
= 1 then it will print 127.
X1*1!
+ X9*3! + X25*5! + X49*7! + X81*9! + . . . + Xn2*n!
function
QUESTION4() %Function
Start
n=input('ENTER THE VALUE OF N = '); %Input n from user
x=input('ENTER THE VALUE OF X = '); %Input x from user
k=1;
sum=0;
while k<=n %Loop k to n
fact=1;
for i=n:-1:1
fact=fact*i; %Calculate Factorial of each
n
end
k=k*k;
temp=x^k;
temp=temp*fact;
sum=sum+temp; %Calculate the sum of
series
k=k+2;
end %END
while
disp('SUM IS: ');
disp(sum); %Display
the sum of series
end %END
of Function
Related posts
- Plot the following MATLAB functions y = ln(exp(x^-1)) with x = 1, 1.5, 2, ..., 4
- Plot the following MATLAB functions: y = exp(-x^2) with x = 0, 0.1, 0.2, ..., 2
- Plot the following MATLAB functions: y = 3x+2 with x = 0, 0.25, 0.5, ...., 7.75, 8
- MATLAB function that takes a matrix as argument and then ask from the user
- MATLAB program which computes the mean and standard deviation of the data. Use FOR LOOPs.
Share this post
0 comments: