Borrar filtros
Borrar filtros

how to create a polynomial interpolation of two variables

4 visualizaciones (últimos 30 días)
merwan behar
merwan behar el 16 de En. de 2023
Comentada: John D'Errico el 18 de En. de 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]

Respuestas (1)

John D'Errico
John D'Errico el 17 de En. de 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 comentarios
merwan behar
merwan behar el 18 de En. de 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 el 18 de En. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by