Converting the Domain of an Array

I have an array of m columns by n rows. The array corresponds to locations on a physical geometry, e.g. the value in cell [1,1] corresponds to the temperature at a physical x and y location. How do I convert my array into a function that can be plotted in the physical domain?

2 comentarios

jonas
jonas el 5 de Dic. de 2018
What do you mean? Do you want to fit a surface to your data, plot the scattered data points or interpolate and plot?
NH3
NH3 el 5 de Dic. de 2018
Editada: NH3 el 5 de Dic. de 2018
Interpolate and plot.
Essentially, I am looking to convert the value in cell [1,1] to a solution to a function when x=0 and y=0, the value in cell [2,1] to the solution to the function when x=0 and y =0.25...and so on.

Iniciar sesión para comentar.

 Respuesta aceptada

jonas
jonas el 5 de Dic. de 2018
Editada: jonas el 5 de Dic. de 2018

0 votos

Read about scatteredInterpolant and post some data if you need help. Using meshgrid and griddata would probably suffice, but your description leads me to believe scatteredInterpoland is what you're looking for.
Use surf(x,y,z) or contourf(x,y,z) to plot. Note that you must interpolate z to a rectangular grid first, using the functions suggested above.

3 comentarios

NH3
NH3 el 5 de Dic. de 2018
Say I have the following array:
x=[1,2,3,4,5;6 7 8 9 10; 11 12 13 14 15]
A contour plot of this array goes from 1 to 5 on the horizontal axis and 1 - 3 on the vertical axis.
contour(x,'Fill','on')
I want to change the horizontal axis to x=0 through x=0.25 and the vertical axis from y=0 to y=0.1.
The points in my current array correspond to physical locations on my geometry.
jonas
jonas el 5 de Dic. de 2018
I assume your example array denoted x is actually z-data? When you pass a single array to contour, then it is interpreted as z-data and the indices are interpreted as xy-data. You can also pass xy-data to contour, which in your case are spatial coordinates. This can be really easy, if your data is already gridded, and a little bit harder if your data is scattered.
Try this:
T = [1,2,3,4,5;6 7 8 9 10; 11 12 13 14 15];
x = linspace(0,0.25,5);
y = linspace(0,0.1,3)
contourf(x,y,T)
NH3
NH3 el 5 de Dic. de 2018
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Preguntada:

NH3
el 5 de Dic. de 2018

Comentada:

NH3
el 5 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by