MATLAB Answers


How can I increase the resolution of Contourf plot?

Asked by Parham Ebrahimi on 21 Aug 2019
Latest activity Commented on by Parham Ebrahimi on 26 Aug 2019 at 8:16
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?


Can you share "Contourf plot"?
%% the normal resolution
Z=%some values in a 8 times 8 matrix
%% To increase resolution
%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

Sign in to comment.

1 Answer

Answer by Steven Lord
on 21 Aug 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 Comment

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.

Sign in to comment.