How to plot the real function not just points in matlab?
Afficher commentaires plus anciens
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

%
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 8 Nov 2015
0 votes
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 commentaires
Karim Belkhiria
le 8 Nov 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
le 9 Nov 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.
Catégories
En savoir plus sur Spline Postprocessing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
