MATLAB: The dimension of the input vector in the imagesc function

imagesc vector dimensionMATLAB

I used the sample data in the attachment and got the result of Figure 1 when using the imagesc function, but I expected the result to be Figure 2.
(Note: XData, YData, and C in the imagesc () function correspond to the first, second, and third columns in the sample data, respectively.)
I want to ask how the dimensions of the matrix should be adjusted to be similar to the result in Figure 2. Thank you.
figure1
figure 2

Best Answer

For this type of scattered data you can use scatter, something like this:
scatter(data(:,1),data(:,2),23,data(:,3),'filled')
or if you want to reinterpolate to a regular grid you can use any of griddata, TriScatteredInterp, or scatteredInterpolant.
HTH
Related Question