Filter löschen
Filter löschen

how to create a polynomial interpolation of two variables

4 Ansichten (letzte 30 Tage)
merwan behar
merwan behar am 16 Jan. 2023
Kommentiert: John D'Errico am 18 Jan. 2023
how to create a polynomial interpolation of two variables with following data:
x=0:0.5:2;
y=0:0.1:0.4;
z=[13.2689 14.8741 16.4243 17.9337 19.4118]

Antworten (1)

John D'Errico
John D'Errico am 17 Jan. 2023
Sorry, but this is a common mistake made by people.
You really have only ONE variable there, since x and y are linearly related. Therefore you cannot perform a TWO dimensional interpolation.
x=0:0.5:2;
y=0:0.1:0.4;
plot(x,y,'o')
You CAN perform an interpolation of z as a function of x, or z as a function of y. They will be identical mathematically, due to the linear relationship between x and y.
  5 Kommentare
merwan behar
merwan behar am 18 Jan. 2023
I want to draw a two-dimensional graph, I can't do it with the surface function .
as the following figure
John D'Errico
John D'Errico am 18 Jan. 2023
You don't have two dimensions of information content in your data. Wanting to do something is nice. But wanting the mathemtically impossible is not enough.
As I showed, your data lives only perfectly along a straight line. And that makes it impossible.
You need to get data that provides information in TWO dimensions. Not just one. Again, here is your data in the (x,y) plane:
x=0:0.5:2;
y=0:0.1:0.4;
plot(x,y,'o-')
Do you see that the data lives along a straight line?
Instead, you want data that looks like this:
xgood = [0 1 2 0 1 2 0 1 2];
ygood = [0 0 0 .2 .2 .2 .4 .4 .4];
hold on
plot(xgood,ygood,'rs')
The data in red is data that explores the entire domain. And it allows you to draw the surface you want to see. The data you have is sadly, completely useless in this respect.
You need to understand the difference.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by