0
下面的編碼是解決從熱模型中解耦的連續性方程 我需要根據編碼產生冰厚度的3D圖形 h_t = B +(D h_x)_x D = Gam | h_x |^(N-1)H ^(N + 2)使用matlab的網格函數
n=3;
L=750000; % meters
dtyear=10;
Nx=30;
type=1;
Mt=ceil(25000/dtyear);
dx=(2*L)/Nx; x=-L:dx:L; % x grid
xmid=-L+dx/2:dx:L-dx/2; % midpt grid
xplot=linspace(-L,L,400); % for plotting analytical soln
iceconstants; %Gam=2*(rho*g)^n*A;
% constants related to grid
dt=dtyear*SperA;
R0=dt/(dx*dx); % presumed related to stability for continuity eqn
Tend=dt*Mt; % final time
t=0:dt:Tend;
% use either steady state analytical soln or zero as initial condition
ic=hexact;
%ic=zeros(1,Nx+1);
% allocate space for solutions
hh=zeros(Nx+1,Mt+1); % hh(j,l) with j for x and l for t
D=zeros(Nx+1,1); %column vector
hh(:,1)=ic'; %insert initial condition
%enforce boundary conditions at start
hh(1,:)=0; hh(Nx+1,:)=0;
D(1)=0; D(Nx+1)=0; % see steady bdry
for l=1:Mt
delh=(hh(2:Nx+1,l)-hh(1:Nx,l))/dx; % Nx by 1 column vector
hav=(hh(2:Nx+1,l)+hh(1:Nx,l))/2; % Nx by 1 col vect
Dmid=(Gam/(n+2))*hav.^(n+2).*abs(delh).^(n-1); % Nx by 1 col vect
F=Dmid.*(hh(2:Nx+1,l)-hh(1:Nx,l));
hh(2:Nx,l+1)=hh(2:Nx,l)+B*dt+R0*(F(2:Nx)-F(1:Nx-1));
end;
tplot=t(tt);
hplot=hh(:,tt);
subplot(3,1,3), mesh(tplot/SperA,x/1000,hplot), view(37.5,30); <--problem in this line
當我運行這種編碼,我得到這樣的結果
the result shows like this :
??? Error using ==> mesh at 80
Data dimensions must agree.
Error in ==> iceA at 144
subplot(3,1,3), mesh(tplot/SperA,x/1000,hplot), view(37.5,30);
這是什麼意思 「的數據維度必須同意」? 我真的很感激,如果u能幫助我:
這太專門化了,可能是由於矩陣/向量的採樣或索引錯誤。嘗試模擬錯誤,用更少的/隨機的樣本來理解參數和調用'mesh'。 – gevang 2013-03-16 04:41:53