How can I plot a function i can´t define before calculating it?
1 view (last 30 days)
Show older comments
X = [1,2,4,5, 17, 34];
Y = [8,14,25,1,-3,27];
syms x;
sum = 0;
for i = 1: length(X)
u = 1;
l = 1;
for j = 1: length(X)
if j ~= i
u = u * (x - X(j));
l = l * (X(i)-X(j));
end
end
sum = sum + ((u/l)*Y(i));
end
disp(simplify(sum));
fplot(sum(x));
I´m trying to use Lagrange´s method for finding a polynomial, but after finding it i can´t plot the function "sum".
Is there a way to do that?
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots 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!