How do I plot a contour plot using my data?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
%.nc file is from: https://psl.noaa.gov/data/gridded/data.noaa.ersst.v5.html its called sst.mnmean.nc
clear all;
%SST from Jan 1854-Sep 2021, Precip from Jan 1948-Dec 2020
sst=ncread('sst.mnmean.nc','sst');
time = ncread('sst.mnmean.nc','time');
lat=ncread('sst.mnmean.nc','lat');
lon=ncread('sst.mnmean.nc','lon');
SST1 = sst(:, :, 1753:end);
SST2 = SST1(:,:,1:252);
%SST2 shows 1:252 being the number of months from January 2000 to December 2020. SST2 is 180x89x252 single which is lon by lat by time.
Months = 1:252
Months1 = Months(7:12:252) %I want to find all of the July's of every year so I would have a 180x89x21 since it's 21 July's from 2000-2020
data_jul2 = SST2(:,:,Months1); %This is where the data becomes 180x89x21
monthly_means = mean(data_jul2,3); %I was trying to take the monthly mean of every July and still get the same dimensions but I got a 180x89
data_mat_ac_removed = data_jul2 - monthly_means; %Won't let me plot this 3D into a contour or contourf plot
figure(1);
hold on
contourf(data_mat_ac_removed) %This is the contour plot I tried I also tried contourf(lon,lat,data_mat_ac_removed)
%Both of these I got the error: Error using contourf (line 55), Input arguments must have at most 2 dimensions.
END OF MATLAB CODE!
.nc file is from: https://psl.noaa.gov/data/gridded/data.noaa.ersst.v5.html

0 Commenti
Risposte (1)
KSSV
il 8 Ott 2021
Your input is a 3D matrix. contourf needs 2D matrix to plot contours. Input a 2D matrix.
for i = 1:size(data_mat_ac_removed,3)
contourf(data_mat_ac_removed(:,:,i))
drawnow
pause(0.1)
end
3 Commenti
Vedere anche
Categorie
Scopri di più su Contour Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!