for loop and function handle
Mostra commenti meno recenti
Hello, I would really appreciate an answer as this is driving me crazy.
I have a system of PDE, and I have a plate geometry. I have stored the values of the edges in the perimeter in one vector and the values of the inner edges in another vector.
When I apply boundary conditions to the perimeter:
in=0;
for k = 1:numel(perimeter)
edge = perimeter(k);
in=in+1;
bcfunc= @(location,state) mybc(location,state,dis,ts,in);
applyBoundaryCondition(modelTwoDomain,"mixed","Edge",[edge,edge],"u",bcfunc,"EquationIndex",1,"q",[0 0],"g",0);
end
in=0;
where
function bcMatrix = mybc(location,state,acs,ti,i)
T=state.time;
% Check if T is NaN and assign the previous value if true
if isnan(T)
%T = previousTime;
vq = NaN(size(location.x));
else
%previousTime = T; % Update previousTime with the current value of T
ac = acs(i,:);
vq = interp1(ti, ac, T);
end
bcMatrix = vq;
end
it works. I pass dis, a matrix containing rows that represent the displacement of every edge in the perimeter, ts the time measurement and in and index to move along the rows depending on the edge.
Now instead of the perimeter I want to do the same in the inner edges, the values stored in inedges
in=0;
for k = 1:numel(inedges)
edge = inedges(k);
in=in+1;
bcfunc= @(location,state) mybc(location,state,dis,ts,in);
applyBoundaryCondition(modelTwoDomain,"mixed","Edge",[edge,edge],"u",bcfunc,"EquationIndex",1,"q",[0 0],"g",0);
end
in=0;
and in this ocasion, the corresponding edges do not enter into mybc, so it does not apply the boundary conditions. Am I missing something here?This is driving me crazy as it does not make sense
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Windows in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!