What format should my Z values be when making a contour plot?

Hey everyone. hope you're doing good. I'm trying to display temperature variations in a fjord in a two dimensional space. The X axis is the latitude of the sample and the Y axis is the depth at which the temperature was measured.
This is my code:
CTD = xlsread('komplett_CTD.xlsx');
LAT = CTD(:,6);
D = CTD(:,8);
T = CTD(:,9);
contour(LAT,D,T);
set(gca,'Ydir','reverse')
"CTD" is a 579x20 double, so "LAT", "D" and "T" are 579x1 doubles.
here's the error message:
Error using contourf (line 57)
Z must be at least a 2x2 matrix.
Error in Profiler (line 18)
contourf(LAT,D,T,20);
I don't know where to go from here. If the Z values are coupled with each respective X,Y-pair, then why can't Z be just a nx1 double? How can i turn it into the correct format?
Thankful for answers. /Max

 Accepted Answer

contourf(LAT,D,repmat(T,1,numel(D)),20); % or repmat(T,1,numel(D))' if that doesn't work

More Answers (0)

Products

Release

R2018b

Community Treasure Hunt

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

Start Hunting!