Use of command reshape
Afficher commentaires plus anciens
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
Réponses (1)
darova
le 30 Juil 2019
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)
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!