Filter löschen
Filter löschen

How can I plot this code using the "plot" function?

1 Ansicht (letzte 30 Tage)
Emilio Ortega
Emilio Ortega am 29 Sep. 2017
Beantwortet: Walter Roberson am 29 Sep. 2017
x = [-1 0 1 2];
y = [1 2 -1 2];
P = cod_lagrange(x,y); %los coef aparecen de la forma Ax^n + Bx^n-1 + ... + D
pretty(poly2sym(P))
%polyval(P,1.5) %para evaluar el polinomio en un punto (1.5 en este caso)
SP = poly2sym(P); %Guardo en SP el polinomio
figure
ezplot(SP,[-1.0 2.0])
fplot(SP,[-1.0 2.0])
if I do
z = 1: .5: 2
plot (z, SP)
gives error because SP is type "sym" Matlab says: "Error using plot Data must be numeric, datetime, duration or an array convertible to double."

Antworten (1)

Walter Roberson
Walter Roberson am 29 Sep. 2017

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by