Use of command reshape

1 回表示 (過去 30 日間)
Riccardo Rinaldi
Riccardo Rinaldi 2019 年 7 月 30 日
回答済み: darova 2019 年 7 月 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

回答 (1 件)

darova
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)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by