Matlab欧拉法

时间:2019-09-27 02:11:00

标签: matlab

我应该使用eulers方法找到地球上所有纬度(-90S至90N)和海拔高度(0至22km)的纬向风场

%Wind speed = 0 at surface

a = -12;

b_1 = 40;

x = -90:1:90; %latitude

y = 0:1:22; %altitude

z_r = 12;

[X, Y] = meshgrid(x, y);

%dy_dx = (y_2 - y_1)/(x_2 - x_1)

T = a + (b_1*(1-Y/z_r)).(3./2(2./3 + (sin(Xpi/180)).^2).(cos(X*pi/180)).^3);

contourf(X,Y,T,'ShowText','on')

colorbar

title("Temperature field")

xlabel("Latitude (degrees)")

ylabel("Altitude (km)")

%all code works above this line as it should. You can plot this and you will see what is be happening in this simple model.



%gravity in km/s

g = 0.0981

%f = coriolis force

f = (1.458*10^(-4))sin(Xpi/180);

%here I'm trying to use eulers method to find the zonal wind field everywhere on earth

for i = 1:22

   for j = 1:180

      i(i,j) = 0

   end

end

for i = 1:22

   for j = 1:180

     dtdy(i, j+1) = (T(i, j+1) - T(i, j))./(Y(i, j+1) - Y(i, j))

     u(i+1, j) = u(i, j) - ((g./(f*T(i, j))).dtdy(i, j+1)*(X(i+1, j) - X(i, j)))./111.21
end
end

%我得到一个错误,说矩阵尺寸必须一致,但是我对Matlab并不十分精通,所以我不确定为什么。

0 个答案:

没有答案