How can I plot a function i can´t define before calculating it?

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

David Hill
David Hill il 19 Ott 2020
fplot(sum);
  1 Commento
Jose Ramirez
Jose Ramirez il 19 Ott 2020
Thanks! I had tried it but didn´t notice until now that the issue is actually the scale, it somehow seems off.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by