How to pass multiple vectors (possibly a matrix) to pdepe and output a respective vector matrix?

조회 수: 3 (최근 30일)
Hi!
I have a matrix of parameters (lets say a design of experiments) which I would like to pass to pdepe and obtain a numerical output. That output will be used to calculate the flux and the flux is multipled by a bunch of constants to obtain my quanitity of interest. I want to then bunch up the quanity of the interest in a vector of similar dimensions to the experimental output to be able to fit coefficients to my coupled equations.
I need a way to pass my parameter matrix (lets say) x to obtain my I_num.
  댓글 수: 6
Torsten
Torsten 2022년 5월 1일
Pass the values of alphaa to the functions of pdepe where they are needed, e.g.
icfun = @(x) Uinit(x,alphaa(1))
sol = pdepe(m,pdefun,icfun,bcfun,xmesh,tspan,options)
function u0 = Uinit(x,alphaa)
u0 = alphaa;
end
Hashim
Hashim 2022년 5월 1일
편집: Hashim 2022년 5월 1일
alphaa = [2.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
6.00000000000000e-06,4.46000000000000e-06,4.54444000000000e-07;
7.00000000000000e-06,5.46000000000000e-06,5.54444000000000e-07;
8.00000000000000e-06,6.46000000000000e-06,6.54444000000000e-07;
9.00000000000000e-06,7.46000000000000e-06,7.54444000000000e-07;
7.00000000000000e-06,8.46000000000000e-06,8.54444000000000e-07];
Let's say this is our alphaa respectively for every row N I want a solution matrix. This is what I am struggling with atm. Using this solution matrix I want to calculate I_num which would be a vector 6*1. I am trying to use a loop with no success so far. Looks like this so far:
for i=1:length(tspan)
ic_arg(i) = {@(x)alphaa(i,1).*ones(size(N)) ; @(x)alphaa(i,2).*ones(size(N)); ...
@(x)alphaa(i,3).*ones(size(N))};
IC(i) = @(x)PDE_PSw_EK_IC(x, ic_arg(i));
BC = @(xl, yl, xr, yr, t)PDE_PSw_EK_BC(xl, yl, xr, yr, t, epsilon, alphaa);
optns = odeset('MaxStep',1e-00,'RelTol',1e-7,'AbsTol',1e-7);
sol1(i) = pdepe(m, @(x, t, y, DyDx)PDE_PSt_EK(x, t, y, DyDx, beeta, alphaa), ...
IC(i), BC, x, tspan, optns);
end
Pretty sure i will have to loop through my BCfun as well considering it has terms from alphaa as well.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2022년 5월 2일
optns = odeset('MaxStep',1e-00,'RelTol',1e-7,'AbsTol',1e-7);
for i=1:size(alphaa,1)
INIT = @(x) alphaa(i,1:3);
BC = @(xl, yl, xr, yr, t)PDE_PSw_EK_BC(xl, yl, xr, yr, t, epsilon, alphaa);
PDE = @(x, t, y, DyDx)PDE_PSt_EK(x, t, y, DyDx, beeta, alphaa)
sol{i} = pdepe(m, PDE,INIT, BC, x, tspan, optns);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by