Matrix Dimensions must agree.. Help Please

Hello, I cannot seem to get my dimensions to agree. The error starts at line:
"v = (g/f)*dh_x./dx; % Meridional geostrophic velocity v"
%% #1 Figure 1
load xyeta.mat
figure
pcolor(x,y,eta)
shading interp
c = colorbar;
ylabel(c,'\eta (m)')
xlabel('Longitude (^oW)')
ylabel('Latitude (^oN)')
title('Sea Surface Elevation Map (in/m) / B. Guyton 05/03/2022')
hold on
%%%% #1 Figure 2
% geostrohpy, need to add f and rho
g = 9.81; % Gravitational acceleration (m/s2)
mlat = mean(y); % Mean lattitude of our area
dh_x = diff(eta,1,2);
dx = diff(x(1:2))*111320*cosd(mlat); % in meters
dh_y = diff(eta,1,1);
dy = diff(y(1:2))*110574;
%[FX,FY] = gradient(ssh);
Omega = 7.2921e-5; % Earth's rotation speed (rads/s)
f = 2*Omega*sind(mlat); % Coriollis Parameter
v = (g/f)*dh_x./dx; % Meridional geostrophic velocity v
u = -(g/f)*dh_y./dy; % Longitudinal geostrophic velocity u
% mid points of calculation
lat1 = (y(1:end-1) + y(2:end))/2;
lon1 = (x(1:end-1) + x(2:end))/2;
% throw away extra data so we have matching dimensions
v = v(2:end,:);
u = u(:,2:end);
% plot currents
hold on
quiver(lon1,lat1,u,v,'w')
xlim('auto')
ylim([-30.00 -0.13])
% plot zoom in area
plot([37 37 42 42 37], [-20 -15 -15 -20 -20],'r')
% zoomed in figure around eddy
figure
pcolor(x,y,eta)
shading flat
axis equal
c = colorbar;
ylabel(c,'h (m)')
hold on
scale=0.2; % Ploting scale
quiver(lon1,lat1,u*scale,v*scale, 0,'w')
axis([37 42 -20 -15])
quiver(38,-15.5,1*scale,0,0,'k')
text(38.1,-15.3,'1m/s')
ylabel(c,'\eta (m)')
xlabel('Longitude (degs)')
ylabel('Latitude (degs)')

回答 (1 件)

Torsten
Torsten 2022 年 4 月 28 日
編集済み: Torsten 2022 年 4 月 28 日

0 投票

You work with vectors. So you must use
v = (g./f).*dh_x./dx; % Meridional geostrophic velocity v
u = -(g./f).*dh_y./dy; % Longitudinal geostrophic velocity u
instead of
v = (g/f)*dh_x./dx; % Meridional geostrophic velocity v
u = -(g/f)*dh_y./dy; % Longitudinal geostrophic velocity u

カテゴリ

ヘルプ センター および File ExchangeVector Fields についてさらに検索

質問済み:

2022 年 4 月 28 日

編集済み:

2022 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by