Clear Filters
Clear Filters

Time based conditional statement

3 views (last 30 days)
Lauren
Lauren on 11 Oct 2023
Edited: Walter Roberson on 12 Oct 2023
I am in a class based on estuaries and we were told to write a conditional flux statement to track nitrogen concentration.
I want to condition to show 1000 mg N/L for the first 10 hours, and then I want it to drop to zero. I am supposed to enter this as a left boundary condition. Could anyone tell me how to write a code for this condition? Thank you!
This is what that part of my code looks like currently
Boundary conditions
function [pl,ql,pr,qr] = pdex1bc(xl,cl,xr,cr,t)
pl = 1000; % ***
ql = 1; % ***
pr = cr - 0; % ***
qr = 0; % ***
% Concentration (c): pi = ci - Conci; qi = 0 (i = l,r)
% Flux (F): pi = Fi; qi = 1 (i = l,r)

Answers (1)

Walter Roberson
Walter Roberson on 11 Oct 2023
I have not used the pde functions myself. I have, however, used the ODE functions, and knowing something about those and reading the documentation https://www.mathworks.com/help/matlab/ref/pdepe.html it looks to me as if you should have time-dependent boundary conditions in a single call.
Instead, what you should do is make two calls with two different tspan. The first one would be out to 10 hours, and the second one would start from 10 hours and run to whenever. You would use the outputs of the first call as inputs to the second call. You would have arranged 1000 mg N/L as the value for the first call, but 0 as the value for the second call.

Products

Community Treasure Hunt

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

Start Hunting!