For loops and taylor series
Show older comments
I am having issued with my for loop taking the variable that i have set to be [1:1:n] but when i run my script it turns my answer into a scular in stead of a matrix.
here is what i have any help would be great thanks.
clc;
clear;
close all;
n = input('Please give number for the total number of terms in the taylor series: ');
x = input('Please give a value for "x": ');
approxValue = 0;
% Initial value of approxValue.
for k = [0:1:n];
approxVakue = (approxValue + k);
approxValue = sum(x.^k/factorial(k));
% Gives the approx value of e^x as a taylor series
end
disp('approxValue =')
disp((approxValue))
disp('e^x =')
disp(exp(x))
1 Comment
Dillan Masellas
on 8 Apr 2016
How can I perform this operation without using the power function?
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!