How to plot the real function not just points in matlab?
Mostrar comentarios más antiguos
I am trying to plot the function that is defined by the points (xi,yi), but I am just getting a plot of the points that i gave, connected through lines.
here is my function:
function c = interpolation(x, y)
n = length(x);
V = ones(n);
for j = n:-1:2
V(:,j-1) = x.*V(:,j);
end
c = V \ y;
disp(V)
for i = 0:n-1
fprintf('c%d= %.3f\n', i, c(i+1));
end
plot (x,y)
hold on
plot (x,y,'o')
end
how to get the real curve? is the a possibility to plot the real curve, plus that points noted as 'o' in the plot?
Thank you in advance

%
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 8 de Nov. de 2015
0 votos
No. "real curves" have Aleph 1 points in them, the infinity of real numbers. You cannot plot a "real" curve with any finite set of points. MATLAB can only ever generate a finite set of points when operating with a finite amount of memory in a finite time. Therefore MATLAB cannot be used to plot "real" curves, only approximations of curves.
3 comentarios
Karim Belkhiria
el 8 de Nov. de 2015
What is the "real function"? We can see in the screenshot that you are plotting this by calling your MATLAB function with two vectors of four values each:
v1 = [-1,0,1,2];
v2 = [5,-2,9,-4];
And these are exactly the four points that are plotted.
So you define four points in space, and do not define any function between them. There are exactly infinite functions that will exactly fit those four points (or any finite set of points), so which one of these infinite possibilities would you select as being the "real function"?
It seems that perhaps you are asking about interpolation or perhaps smoothing, which any internet search engine can tell you about.
Walter Roberson
el 9 de Nov. de 2015
You have to be careful with the wording there, Stephen. "exactly infinite functions" implies the ability to compare infinities for equality, which you can do for countable infinity but countable infinity is not equal to uncountable infinity. The number of functions that can fit any finite set of points is uncountable infinity.
Categorías
Más información sobre Spline Postprocessing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
