Plotting Eddy Kinetic Energy

조회 수: 49 (최근 30일)
Desak Made Pera Rosita Dewi
Desak Made Pera Rosita Dewi 2021년 4월 3일
답변: Nipun 2024년 6월 6일
Hi I have problem with plotting eddy kinetic energy (EKE)
I have a data of sea surface height (variable name: adt) with matrix [n m k]. n is latitude, m is longitude and k is time.
I want to plot EKE with equation below
here is my initial code
regionName = 'SouthIndian' % change as you need to ..
eval(['load ' regionName]); %to evaluate the data
[n, m, k] = size(b.adt); %n =lat, m= lon, k = absolute topohraphy
adt_mean = squeeze(mean(shiftdim(b.adt,2)));
g=(9.8).^2;
f=2.*(coriolisf(b.lat)).^2;
dhx=(diff(adt_mean)./diff(b.lat)).^2;
dhy=(diff(shiftdim(adt_mean,1))./diff(b.lon)).^2;
eke=g/f*(dhx+dhy);
But it doesnt working. Plese help or any suggestion about it.
  댓글 수: 2
Desak Made Pera Rosita Dewi
Desak Made Pera Rosita Dewi 2021년 4월 3일
matlab said the matrix size do not match
Amilton Roberto Muhosse
Amilton Roberto Muhosse 2023년 5월 23일
I DO NOT UNDERSTAND WHAT IS ABSOLUTE P=TOPOGRAPHY

댓글을 달려면 로그인하십시오.

답변 (1개)

Nipun
Nipun 2024년 6월 6일
Hi Desak,
I understand that you want to calculate and plot the Eddy Kinetic Energy (EKE) from sea surface height (adt) data. Based on the shared information about the code, I can confirm that the root cause of the problem is dimension handling and related calculation.
Here is the recommended version for the expected output:
regionName = 'SouthIndian'; % change as needed
eval(['load ' regionName]); % load the data
% Extract dimensions
[n, m, k] = size(b.adt); % n = lat, m = lon, k = time
% Compute the mean absolute dynamic topography (adt) over time
adt_mean = mean(b.adt, 3);
% Constants
g = (9.8)^2;
% Compute Coriolis parameter squared (f^2)
f = 2 * (coriolisf(b.lat)).^2;
% Calculate spatial derivatives
[lat_grid, lon_grid] = meshgrid(b.lat, b.lon);
dhx = (diff(adt_mean, 1, 1) ./ diff(lat_grid, 1, 1)).^2; % Gradient in lat direction
dhy = (diff(adt_mean, 1, 2) ./ diff(lon_grid, 1, 2)).^2; % Gradient in lon direction
% Extend the matrices to original size by padding with zeros
dhx = padarray(dhx, [1, 0], 'post');
dhy = padarray(dhy, [0, 1], 'post');
% Compute EKE
eke = g ./ f .* (dhx + dhy);
% Plotting EKE
figure;
imagesc(b.lon, b.lat, eke');
set(gca, 'YDir', 'normal');
colorbar;
title('Eddy Kinetic Energy (EKE)');
xlabel('Longitude');
ylabel('Latitude');
For more information on the functions used, refer to the following MathWorks documentation:
  1. "coriolisf" : https://www.mathworks.com/matlabcentral/fileexchange/47338-coriolisf
  2. "padarray" : https://www.mathworks.com/help/images/ref/padarray.html
  3. "meshgrid" : https://www.mathworks.com/help/matlab/ref/meshgrid.html
Hope this helps.
Regards,
Nipun

카테고리

Help CenterFile Exchange에서 Oceanography and Hydrology에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by