where is the error? lagrange

16 vues (au cours des 30 derniers jours)
Dasom Kim
Dasom Kim le 3 Mai 2020
Modifié(e) : Ameer Hamza le 3 Mai 2020
when i execute this code, error comes in y^lag;
how can i fix it?
function approx = lagrange(x,y,x_bar)
n = length(x);
for i = 1:n
value = ones(1,length(x_bar));
for k = 1 : n
if k ~= i
value = value.^(x_bar-x(k))/(x(i)-x(k));
end
end
lag (i,:) = value ;
end
approx = y^lag;
end

Réponses (1)

Ameer Hamza
Ameer Hamza le 3 Mai 2020
Modifié(e) : Ameer Hamza le 3 Mai 2020
Use element-wise exponential operator
approx = y.^lag;

Catégories

En savoir plus sur Matrix Decomposition dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by