How to express a function both time and spatial dimension dependent?
古いコメントを表示
Hi there,
It seems an easy one but I guess it is not that easy. I have a fluid flowing through a vessel. I want to measure its velocity u1 and u2. the vessel coordinetes from the lateral position x=0 to x=1 in time from t=0 to t=3. The code is :
ii=101;
dt=0.1;
t = 0:dt:10;
dx=0.01; %step size
fik=0.4;
for i=1:ii;
x=(i-1)*dx;
H1D=0.1;
H1=0;
A=0;
AD=0.1;
fikness=fik*sin(pi*x);
ub1(i)=(c1b-H1D*(x-0.5)+AD/2*(x-0.5)^2)/(H1-0.5*fikness-A*(x-0.5));
ub2(i)=(c2b+H1D*(x-0.5)-AD/2*(x-0.5)^2)/(1-H1+0.5*fikness+A*(x-0.5));
end
H1D=H1D+dt*H1DDOT %------lets say these H1D, H1DDOT, H1 are time dependent functions.
H1=H1+dt*H1
AD=AD+dt*ADDOT;
A=A+dt*AD
Matlab runs the program above but it is not showing time. For example if I want to see in time t=2 what are the velocities u1 and u2 over the whole vessel (from x=0 to x=1)? How can I plot and see the results Thanks in advance
回答 (1 件)
Amit
2014 年 1 月 27 日
Well, your time is stored in vector t. So lets say you want to plot ub1 versus time, it will be:
plot(t,ub1);
3 件のコメント
Amit
2014 年 1 月 27 日
I think there is something wrong in this code too. You are not looping through time actually. I think this code is done to get velocities at t = 0.1 sec. You did not go further.
You have to loop through time as well.
Just a piece of advice: Matlab have good numerical integrators like ode45 which is more stable that simple euler forward integration that you're doing here.
Meva
2014 年 1 月 27 日
Amit
2014 年 1 月 27 日
Like I said, you have done your calculation for the first time step only. You need to go through more time loops.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!