MATLAB: Contour plot based on xyz data

contourplot

I have xyz data as attached. X is longitude, y is altitude and z is electron density. For each value of longitude from 75 to 95, I have altitude values of 100 to 2000 with corresponding electron density values for each altitude. I want a colored contour plot with these data. Please help.

Best Answer

Your data are gridded. You only need to reshape them into your ‘X’, ‘Y’, and ‘Z’ matrices:
D = load('data_new.txt');
[Du,D1] = unique(D(:,1));
Dd = diff(D1);
Dr = reshape(D, Dd(1), [], size(D,2));
X = Dr(:,:,1);
Y = Dr(:,:,2);
Z = Dr(:,:,3);
figure
contourf(X, Y, Z)
See the documentation on contourf (link) for details on how to customise it.