Contourf with irregular spaced points

3 views (last 30 days)
Contourf works if I define X and Y as monotonic increasing values. For eg.,
X=[1:3]; Y=[1:3]; Z=[10 20 30; 40 50 60; 70 80 90]; contourf(X,Y,Z);
Now, when I want to plot using contourf, but with irregular values of X, Y, for the same Z value, how will I go about this? For eg.,
X=[ 1.3 2.2 3.1 1.9 2.7 3.6 2.4 3.2 4.1];
Y=[-0.3 0.1 0.6 -1.2 -0.7 -0.2 -2.1 -1.6 -1.1];
Z=[10 20 30; 40 50 60; 70 80 90]; contourf(X,Y,Z);
The error msg: "The size of X must match the size of Z or the number of columns of Z."
Thanks,
Ganesh

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jul 2012
You will need to use something like TriScatteredInterp over a regular grid and contour that. contour() and contourf() are not suitable for scattered points.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!