How can I increase the resolution of Contourf plot?

46 visualizzazioni (ultimi 30 giorni)
Hello everyone!
Could you please help me with this:
I have a 8×8 grid which I want to use in order to plot some Z values in the contourf.
However, I interpolated my data to generate more point using griddata function. Now the number of values inside Z matrix ofcourse increases.
What I want to see on the contourf is the new Z matrix but with same (x,y) values. In this way the resolution will increase thanks to more datapoints in Z.
The problem is MATLAB asks for the same dimensions for (x,y) to produce corrosponding values in matrix Z.
Do you know how can I fix this?
  2 Commenti
Parham Ebrahimi
Parham Ebrahimi il 21 Ago 2019
%% the normal resolution
x=1:8;
y=1:8;
[X,Y]=meshgrid(x,y);
Z=%some values in a 8 times 8 matrix
contourf(X,Y,Z)
%% To increase resolution
[xq,yq]=meshgrid(1:0.2:8,1:0.2:8)
vq=griddata(x,y,Z,xq,yq);
%Now Z is 36 times 36!
contourf(Z)%this will give the contourf with increased x,y axis!
%I want to have x and y 8 times 8 and then more values on the contour

Accedi per commentare.

Risposte (1)

Steven Lord
Steven Lord il 21 Ago 2019
contourf(Z)%this will give the contourf with increased x,y axis!
That's correct. What does contourf use as X and Y coordinates if you call it with only one input? From the documentation: "contourf(Z) creates a filled contour plot containing the isolines of matrix Z, where Z contains height values on the x-y plane. MATLAB® automatically selects the contour lines to display. The row and column indices of Z are the x and y coordinates in the plane, respectively."
When you called contourf on your coarser data you passed X and Y in, which "specifies the x and y coordinates for the values in Z." Pass the finer grid coordinates into contourf the same way.
  1 Commento
Parham Ebrahimi
Parham Ebrahimi il 26 Ago 2019
Thanks for your response. The problem is if I input finer grid coordinate in X and Y, an error appears since my Z matrix does not contain more than 64 data. Thus, increasing the resolution of grid causes Matlab to look for more data in the Z matrix it won't interpolate automatically to generate more data.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by