How to interpolate between multiple contour plots?

l have 3 contour plots for 3 values of "f" like one below. Each is plotted with respect to data from "f"; data of the first plot is coming from an Excel file, and the other two comes from different Excel files. Assume the values of f are 1,2,3. I have data for these exact values (1,2,3), but not for the intermediate values. How do l interpolate it to have specific data for the value of f (i.e. f=2.6)?
Thanks in advance!

 Respuesta aceptada

You could probably use interp3 if you concatenate all your 2D matrices together in the 3rd dimension.
See here.
f1 = [1 2 3 ; 4 5 6];
f2 = [10 20 30 ; 40 50 60];
f3 = [100 200 300 ; 400 500 600];
F = cat(3,f1,f2,f3);
x = 1:size(F,2);
y = 1:size(F,1);
f2_6 = interp3(F,x,y',2.6)
f2_6 = 2×3
64.0000 128.0000 192.0000 256.0000 320.0000 384.0000

6 comentarios

That f1, f2, f3 are inconsistent (in my case) would be a problem, wouldn't it?
f1 : 1x25 double
f2 : 1x46 double
f3 : 1x5 double
And there are data points corresponding to f1, f2, f3 locations. For example: (f1(1) , f2(2) , f3(3)) = 0.456
DGM
DGM el 13 de Dic. de 2023
How is your data defined? Both contour()/contourf() expect gridded data, so ZData would be 2D, not vectors. If each ZData vector is associated with corresponding X and Y vectors, then you might be able to start by making them gridded by using griddata() or scatteredInterpolant(). Afterwards, you could do whatever interpolation between them is appropriate. Given the small number of points, I don't know how much meaning I'd place on the results though.
Zdata is 25x46, but there are 5 of them with respect to f3. l'll try to merged it to 25x46x5 to make it appropriate for interp3(f1,f2,f3,Zdata,f_1,f_2,f_3). Am l wrong?
You will need to share your data in order to get an answer for your specific use case. Please save your variables to a mat file and attach it to your post using the paperclip icon. Please also share the code you are using to create your contour plots.
piston_pim_offset
piston_pim_offset el 13 de Dic. de 2023
Editada: piston_pim_offset el 13 de Dic. de 2023
I wish a can share it, but it is not possible. I made Zdata as 25x46x5, implemented interp3, and got desired results. Thanks for your valuable comments.
But now I am not able to plot this data as contours; trying contour3 but it gives error. Do you have any idea for plotting this type of data? (contour(f_1,f_2,f_3) did not work).
Cris LaPierre
Cris LaPierre el 13 de Dic. de 2023
Editada: Cris LaPierre el 13 de Dic. de 2023
Extract the 'sheet' you want and just plot that.
In my example, I would use contour(f2_6)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 12 de Dic. de 2023

Editada:

el 13 de Dic. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by