How to plot the real function not just points in matlab?
이전 댓글 표시
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

%
채택된 답변
추가 답변 (1개)
Walter Roberson
2015년 11월 8일
0 개 추천
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
Karim Belkhiria
2015년 11월 8일
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
2015년 11월 9일
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.
카테고리
도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
