How can I draw contour lines in my problem ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Behrooz Daneshian
am 6 Feb. 2023
Bearbeitet: Voss
am 8 Feb. 2023
Hi all,
I have created cell array(which is attached here) in which the first and second columns representing latitude and longitude of each weather station exisitng in the Alaska state. The third column is the probability that freezing depth in that station exceeds 1 feet. What I want to do is plot contour lines represing the probability values. Can anyone help me with regard?
0 Kommentare
Akzeptierte Antwort
Voss
am 6 Feb. 2023
load Behi1
data = cell2mat(POFDE1);
I = scatteredInterpolant(data(:,[1 2]),data(:,3));
[lat,lon] = meshgrid(unique(data(:,1)),unique(data(:,2)));
contour(lon,lat,I(lat,lon),'ShowText','on')
colorbar
Weitere Antworten (2)
Divyank
am 6 Feb. 2023
The contour plot requires z-coordinates to be specified as a matrix and this matrix must have at least two rows and two columns, and it must contain at least two different values. However, the z-coordinates in POFDE1 is 1x273 cell array, according to my understanding of your problem, you can consider using plot3(X, Y, Z) instead of contour after extracting X, Y and Z co-ordinates from POFDE1 cell array in the following way:
% The input needs to be a scalar, vector or a matrix, hence conversion from
% cell array to vector is needed in this case, you might want to construct
% a matrix instead of a cell array to avoid this conversion.
X = cell2mat(POFDE1(:, 1));
Y = cell2mat(POFDE1(:, 2));
Z = cell2mat(POFDE1(:, 3));
plot3(X, Y, Z, '.');
1 Kommentar
Walter Roberson
am 6 Feb. 2023
The user specifically asked for contour lines. Voss shows one way of doing scattered contour.
Walter Roberson
am 6 Feb. 2023
https://www.mathworks.com/matlabcentral/fileexchange/38858-contour-plot-for-scattered-data is a File Exchange contribution for contour lines for scattered data.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!