Invalid data for plotting(using a function)
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I'm trying to plot a function on matlab, I looked up a few answers but none of them work for me.
function f=larange2(func,n)
funky=@(x) (1/(1+x^2));
xi=linspace(-1,1,n);
for i=1:n
yi(i)=func(xi(i));
end
value=1;
zi=linspace(-1,1,100);
l=0;
ziy=[];
valuel=0;
for z=1:100
for i=1:n
value=1;
for c=1:n
if c~=i
value=value*((zi(z)-xi(c))/(xi(i)-xi(c)));
end
if c==n
ziy(z)=(value*yi(i));
end
end
end
end
for i=1:length(ziy)
valuel=valuel+ziy(i);
end
plot(zi,ziy,xi,func);
f=valuel;
end
func is function passed in from another code which is
func=@(x) 1/(1+x^2);
values=larange2(func,3);
SO how do I do this valid, I tried defining the expression in the function itself but that still didn't work.
댓글 수: 1
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!