Invalid data for plotting(using a function)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Walter Roberson
el 11 de Oct. de 2016
In your "for c" loop, what is to be done if c == i and c ~= n?
Respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!