MATLAB: Do I have error during usage of state.time for non-constant boundary condition

nonconstant boundary conditionspdetoolboxstate.time

Dear all,
I am trying to solve a parabolic PDE with imported 3D geometry. I create the model and everything correctly but I decided to implement on one of the faces a boundary condition that depends on the time. Basically, what it needs to do is for each integer time-step say state.time=k we need to access azimuth(state.time). For this purpose I synchronized the time steps as follows:
nframes = 5; tlist = linspace(1,nframes,nframes);
Previously in the code I have specified the function
myufun14= @(region,state)sin(azimuth(state.time))
where I recall that azimuth is a vector. It gave and error :
"Subscript indices must either be real positive integers or logicals"
I tried just to test whether state.time might not return something different from the time steps included in tlist=linspace(1,nframes,nframes). In doing so I just attempted to apply the ceiling function:
myufun14= @(region,state)sin(azimuth(ceil(state.time+1)))
I got the same error:"Subscript indices must either be real positive integers or logicals"
Please could you help me!
Best

Best Answer

You need to write your boundary conditions in the appropriate syntax. I suppose that you are setting a Dirichlet condition on your specified face.
As the documentation states, your boundary function must return an N1-by-M matrix of points, where N1 is the number of equations (probably 1 for your problem), and M is the number of evaluation points, meaning the length of region.x. So if sin(azimuth(state.time)) is a scalar, then your function should be
myufun14 = @(region,state)sin(azimuth(state.time))*ones(1,length(region.x))
It is also possible that the solver would need times other than those you specify. So you might need to change azimuth(state.time) to azimuth(floor(state.time)).
Alan Weiss
MATLAB mathematical toolbox documentation
Related Question