Draw temperature vertical distribution, Plot error
Mostra commenti meno recenti
To see upwelling, I would like to draw the vertical distribution of the temperature for August. If there is no data for August, I would like to draw it using the data for September. There is data for September 2006, but it says there is no data. Please help me
%% 초기화
clear all; close all; clc;
data = readtable('data_line_102.xlsx', 'VariableNamingRule', 'preserve');
date = data{:, 7}; % 날짜 데이터
temp = data{:, 10}; % 수온 데이터
sail = data{:, 11}; % 수심 데이터
dep = data{:, 9};
lon = data{:, 6};
lat = data{:, 5};
line = data{:, 2};
% 날짜 데이터를 datetime 형식으로 변환
date = datetime(date, 'InputFormat', 'yyyy-MM-dd HH:mm');
%% 8월 또는 9월 데이터로 연직 분포 생성
years = 1993:2020;
august_month = 8; % 8월 우선
september_month = 9; % 9월 대체
num_years = length(years);
subplot_cols = 5; % 한 행에 5개 플롯 설정
num_rows = ceil(num_years / subplot_cols); % 필요한 행 수 계산
for row = 1:num_rows
f = figure;
t = tiledlayout(1, subplot_cols, 'TileSpacing', 'Compact', 'Padding', 'Compact');
for col = 1:subplot_cols
year_idx = (row - 1) * subplot_cols + col;
if year_idx > num_years
break;
end
current_year = years(year_idx);
% 8월 데이터를 우선 필터링
filtered_data = data(year(date) == current_year & month(date) == august_month, :);
% 8월 데이터가 없으면 9월 데이터를 필터링
if isempty(filtered_data)
filtered_data = data(year(date) == current_year & month(date) == september_month, :);
end
% 8월과 9월 데이터가 모두 없으면 건너뜁니다.
if isempty(filtered_data)
continue;
end
% 필요한 데이터 추출
temp_month = filtered_data{:, 10}; % 수온 데이터
depth_month = filtered_data{:, 9}; % 수심 데이터
lon_month = filtered_data{:, 6}; % 경도 데이터
[lon_grid, depth_grid] = meshgrid(unique(lon_month), unique(depth_month));
if numel(lon_month) < 2 || numel(depth_month) < 2
warning('데이터 포인트가 충분하지 않습니다. %d년 8월(또는 9월)을 건너뜁니다.', current_year);
continue;
end
temp_grid = griddata(lon_month, depth_month, temp_month, lon_grid, depth_grid, 'linear');
if all(isnan(temp_grid(:)))
warning('보간된 온도 그리드가 NaN 값만 포함하고 있습니다. %d년 8월(또는 9월)을 건너뜁니다.', current_year);
continue;
end
ax = nexttile;
contourf(lon_grid, depth_grid, temp_grid, 15, 'LineColor', 'none');
xlabel('경도 (°)');
if col == 1
ylabel('수심 (m)');
else
ax.YTickLabel = [];
end
xlim([129.588, 130.918]);
ylim([0, 100]);
title(sprintf('%d년', current_year));
set(gca, 'YDir', 'reverse');
colormap(jet(15));
clim([5 20]);
end
cb = colorbar;
cb.Layout.Tile = 'east';
cb.Label.String = '온도 (°C)';
filename = sprintf('E:\\동해냉수대\\정선 8월 연직구조\\August_or_September_Temperature_Row_%d.png', row);
saveas(f, filename);
close(f);
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Geometric Transformation and Image Registration in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
