Invalid data for plotting(using a function)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!