time looping or increment not updating

Hi all,
I have to time loop/time increment with the code: t=deltat:deltat:3600*5;
Even by varying the time t in the for loop I could not find any change. Please suggest me whether the time looping which I had mentioned is correct or else I have to follow some other steps.
When I plot with the output value of F vs -Z at any time I get the same ans. Simila case with plot u vs -Z.
Please help me in time looping/incrementing. Thank you in advance
alpha=(17*pi)/180; %slope angle
dz=200; %depth of water table from the suface
dlz=400; % toltal depth of slope
fi=(25*pi)/180; %friction angle
C=0.004; %4 kpa=0.4 N/cm^2
gsat=0.021; %21 kN/m^3
gw=0.0098; %9.81 Kn/m^3
Dzero=4; %0.0004m^2/s
ksat=1e-3; %e-5 m/s
iz=2e-4; %iz=7.2 mm/h= 2e-4 cm/s
deltat=10; %time step
deltaz=0.8; %space step
T=12*60*60; %time duration of rainfall= 12h to seconds
e=(deltat/deltaz^2)*Dzero*cos(17*pi/180)*cos(17*pi/180);
n=500; % number of nodes
nt=4320; %time step, based on T
Z=linspace(deltaz,400,500); %Depth in cm
%Setup sparse matrix
si=(Z-dz)*cos(alpha)*cos(alpha); %Initial condition ...i.e.
%pressure head @t=0 all along the depth
if true
% code
end
si=si';
a=-e*ones(n,1); % lower Triagonal vectors
% a(1)=0; a(n)=-114.314; a=a';
b=116.314*ones(n,1); % Diagonal vectors
b=b';
c=-e*ones(n-1,1);% Upper trigonal vector
% c(1)=-114.314; c(n)=0; c=c';
d=ones*(n-2:1);
for t=deltat:deltat:3600*5;
for w=2:499
d(w)=e*si(w-1)-112.314*si(w)+e*si(w+1); % Rhs vector
end
if t>T
d(1)=-112.314*si(1)+114.314*si(2)-130.686;
else
d(1)=-112.314*si(1)+114.314*si(2)-167.264; % t<=T
end
d(500)=114.314*si(499)-112.314*si(500)+167.264; % Boundary condition...
%at the bottom of the slope at all values of t
end
A=ones*(n-1:1);
S=ones*(n-1:1);
d=d';
A(1)=b(1); % A(1)=alpha one=b(1)
S(1)=d(1); % S(1)=Rhs(1)
for i=2:n %varies from 2 to n
A(i)=b(i)-((a(i)/(A(i-1))*c(i-1)));
S(i)=d(i)+((a(i)/(A(i-1))*S(i-1)));
end
A=A';
S=S';
u(n)=S(n)/A(n); %u(N-1)=S(N-1)/A(N-1), "M*u=S", solve for u with M known...
% ... trigonal matrix and S= known Rhs vector
for t=deltat:deltat:3600*18;
for j=n-1:-1:1
% for w=10:10:4320
u(j)=(1/A(j))*(S(j)+(c(j)*u(j+1)));
end
end
% disp([t u]);
u=u';
if u(1)<=0 %Check for ponding
Fs=(tan(fi)/tan(alpha))*ones(n,1); %Gravity component
Fs=Fs';
Fw=(-u*gw*tan(fi))./(gsat*Z'*sin(alpha)*cos(alpha)); %Water pressure ...
%component
Fw=Fw';
Fc=C./(gsat*Z'.*sin(alpha)*cos(alpha)); %Cohesion component
Fc=Fc';
F=Fs+Fw+Fc; %FOS for slope
elseif soln(1)<=0 && (t<T)
d(1)=-114.314*si(1)+114.314*si(2)-130.686;
elseif soln(1)>0 &&(t<T)
soln(1)=0;
else
d(1)=-114.314*si(1)+114.314*si(2)-167.264;
end
Fs=(tan(fi)/tan(alpha))*ones(n,1); %Gravity component
Fs=Fs';
Fw=(-u*gw*tan(fi))./(gsat*Z'*sin(alpha)*cos(alpha)); %Water pressure ...
%component
Fw=Fw';
Fc=C./(gsat*Z'.*sin(alpha)*cos(alpha)); %Cohesion component
Fc=Fc';
F=Fs+Fw+Fc; %FOS for slope
if true
% code
end

2 个评论

When you say Even by varying the time t in the for loop I could not find any change, which t are you varying? t is an index in the for loop, so that can't be it. Is it the deltat that you are changing, and if so, to what?
As an aside, you should avoid naming variables i and j, as these are the inbuilt imaginary unit . Accidentally overloading inbuilt functions and variables can cause all sorts of very-difficult-to-figure-out problems later...

请先登录,再进行评论。

回答(2 个)

I didn’t run your code, but it seems that none of your variables inside either of your ‘t’ loops are actually functions of ‘t’. They simply loop endlessly over the same values.

2 个评论

advaita vedanta’s ‘Answer’ moved here:
@Star strider, yes what you mentioned I agree, I am confused on how to assign.
Thank you
What are your original functions?
How are they functions of time?

请先登录,再进行评论。

@Geoff Hayes, I am mentioning time t, actually I want to know the output (u,F) for different values of time t, which I had mentioned in the for loop [not deltat). please correct me. Thank You

Community Treasure Hunt

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

Start Hunting!

Translated by