Use of command reshape
조회 수: 1 (최근 30일)
이전 댓글 표시
I have attached the file giving problems.
I cannot understand why Matlab says that the line 129 (with command reshape) is wrong. The dimension of the final matrix containing the results (for a fixed time) should be (nSpecies + 1, nax, nrad), as written.
If I remove the Energy balances (denoted as "% Energy Balance" in the function packBedFun(~,Y)), the dimension of the matrix becomes (nSpecies, nax, nrad) and the code works.
Can anyone suggest what I should put in place of (nSpecies + 1) at line 129?
Thank you in advance,
RIccardo
댓글 수: 0
답변 (1개)
darova
2019년 7월 30일
nSpecies = 5;
n_ax = 25;
n_rad = 10;
C0 = [0;0;0;0;In];
Y0 = repmat(C0,n_ax,n_rad); % size of Y0 is [125 x 10] (2D matrix)
[tSol,YSol] = ode15s(@packBedFun, [0 50], Y0);
%%
function dY = packBedFun(~,Y)
%% ..
Y = reshape(Y,nSpecies + 1,n_ax,n_rad); % you want to make [6 x 25 x 10] (3D matrix)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!