JOISS 관할해역 해양정보 공동활용시스템은 해양연구자료 전문 리포지토리입니다.
| |

MATLAB

MATLAB

· Matlab에서 JOISS 데이터 다루기  TOP

JOISS에서 다운로드 받은 파일을 아래 코드를 통해 Matlab에서 바로 불러올 수 있습니다.
파일내 주석 처리된 메타정보의 경우 자동으로 필터링 되므로 다운받으신 자료 그대로 사용하시기 바랍니다.
CTD 데이터 다운로드

clear
opts = detectImportOptions('c:/temp/CTD.csv')
%station, date_time, longitude, latitude, 수심_m, 염분_psu, 수온 변수만 선택
opts.SelectedVariableNames = [2,3,4,5,7,8,10]
dat = readtable('c:/temp/CTD.csv', opts)
dat.Properties.VariableNames([1 2 3 4 5 6 7]) = {'stn','일시','경도','위도','수심','염분','수온'}
summary(dat)

%히스토그램(카운트)
sali = table2array(dat(:,6)) %염분
h = histogram(sali)
h.FaceColor = 'blue'
h.FaceAlpha = 0.7
h.EdgeColor = '#808080' %gray

%히스토그램(비율, 곡선)
temp = table2array(dat(:,7)) %수온
h = histogram(temp, 'Normalization', 'probability')
h.FaceColor = '#8359a3' %purple
[f, xi] = ksdensity(temp)
hold on
plot(xi, f, 'LineWidth', 2)
xlabel('Temperature (°C)')
title('Histogram with density curve')

%Q-Q plot
qqplot(sali)
title('염분 Q-Q Plot')

qqplot(temp)
title('수온 Q-Q Plot')

%stn별 평균 수온
grp_tmp = groupsummary(dat, 'stn', 'mean', '수온')
grp_lat = groupsummary(dat, 'stn', 'mean', '위도')
grp_lon = groupsummary(dat, 'stn', 'mean', '경도')
a_tmp = table2array(grp_tmp(:,3))
a_lat = table2array(grp_lat(:,3))
a_lon = table2array(grp_lon(:,3))
col = linspace(1, 10, length(a_tmp))
geoscatter(a_lat, a_lon, a_tmp, col, 'filled')

%stn별 계절별 평균 수온
mon = array2table(month(table2array(dat(:,2))))
dat = [dat mon]
dat.Properties.VariableNames([8]) = {'mon'}
dat_sp = dat(dat.mon==3 | dat.mon==4 | dat.mon==5,:)
dat_su = dat(dat.mon==6 | dat.mon==7 | dat.mon==8,:)
dat_fa = dat(dat.mon==9 | dat.mon==10 | dat.mon==11,:)
dat_wi = dat(dat.mon==12 | dat.mon==1 | dat.mon==2,:)
%봄
subplot(2,2,1)
grp_tmp = groupsummary(dat_sp, 'stn', 'mean', '수온')
grp_lat = groupsummary(dat_sp, 'stn', 'mean', '위도')
grp_lon = groupsummary(dat_sp, 'stn', 'mean', '경도')
a_tmp = table2array(grp_tmp(:,3))
a_lat = table2array(grp_lat(:,3))
a_lon = table2array(grp_lon(:,3))
col = linspace(1, 10, length(a_tmp))
geoscatter(a_lat, a_lon, a_tmp, col, 'filled')
%가을
subplot(2,2,3)
grp_tmp = groupsummary(dat_fa, 'stn', 'mean', '수온')
grp_lat = groupsummary(dat_fa, 'stn', 'mean', '위도')
grp_lon = groupsummary(dat_fa, 'stn', 'mean', '경도')
a_tmp = table2array(grp_tmp(:,3))
a_lat = table2array(grp_lat(:,3))
a_lon = table2array(grp_lon(:,3))
col = linspace(1, 10, length(a_tmp))
geoscatter(a_lat, a_lon, a_tmp, col, 'filled')
%겨울
subplot(2,2,4)
grp_tmp = groupsummary(dat_wi, 'stn', 'mean', '수온')
grp_lat = groupsummary(dat_wi, 'stn', 'mean', '위도')
grp_lon = groupsummary(dat_wi, 'stn', 'mean', '경도')
a_tmp = table2array(grp_tmp(:,3))
a_lat = table2array(grp_lat(:,3))
a_lon = table2array(grp_lon(:,3))
col = linspace(1, 10, length(a_tmp))
set(gcf, 'position', [100,100,800,600])
geoscatter(a_lat, a_lon, a_tmp, col, 'filled')

%시계열
dat_pnt = dat(strcmp(dat.stn, 'es_ES04'),:)
s1 = timeseries(table2array(dat_pnt(:,6))) %염분
s2 = timeseries(table2array(dat_pnt(:,7))) %수온
s1.Name = '염분'
s2.Name = '수온'
subplot(2,1,1)
plot(s1, 'Color', 'magenta', 'LineWidth', 2)
grid on
xlabel('')
subplot(2,1,2)
plot(s2, 'Color', '#006400', 'LineWidth', 2)
grid on
xlabel('')

%상관분석 : 수심, 염분, 수온
set(gcf, 'position', [100,100,800,600])
corrplot(dat_pnt(:,5:7))

 TOP