vpa error in matlab
Show older comments
I have an important problem in writing a program for calculating Lagrange. i want to assume z as parameter. then I face this error:
""Error in MuPAD command: DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use the VPA function instead.""
this is my program:
clear
clc
syms z
x=[0 300 1000 1500 1700 2000 3000 3300 4000 4500 5000]
y=[32.0 122.4 296.4 405.7 447.6 608.4 704.7 761.4 891.9 983 1072.6]
m=z-x
i=1
j=1
L=[1 1 1 1 1 1 1 1 1 1 1]
q=[1 1 1 1 1 1 1 1 1 1 1]
while j<12
if j==1
for i=2:11
L(1)=L(1)-m(i)
q(1)=q(1)*(x(j)-x(i))
end
else
for i=1:(j-1)
L(j)=L(j).*m(i)
q(j)=q(j).*(x(j)-x(i))
end
for i=(j+1):11
L(j)=L(j).*m(i)
q(j)=q(j).*(x(j)-x(i))
end
end
j=j+1
end
e=(y.*L)
o=e./q
k=1
f=0
while k<12
f=f+o(k)
k=k+1
end
ezplot(f)
Answers (0)
Categories
Find more on Common Operations 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!