How do I rectify the problem of [subscripted assignment dimension mismatch; at Line: dmdt(1) = N]? Much Thanks!
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
function dmdt = fyp(t,m)
tspan = [0:33];
%Time intervals (Mins?)
dmdt = zeros (4,1);
% this creates an empty column vector that i can fill with my 4
% derivatives
%SuperSaturation of fluid
%Ci read from graph
%C f(MT)
C = 80.2;
%Ct = C - Mt
% Temperature of Solution (Celcius)
T = [90:-2:24]';
% Brix
Brix = (64.47+0.10336*T+14.20*10.^-4*T.^2-70.2*10.^-7*T.^3);
%Satuation Concentration
CS = (Brix/(100-Brix));
%Supersaturation
%CC = C - CS(sat)
CC = C - CS;
% Nucleation order,b = 1.5
b = 1.5;
%Exponential of Mass of Crystal
Z = 0.4136;
%Density of Crystal
Density = 1588.4/(1+1.116*10.^4*(T-20));
%Shape Factor (Cube Shape, 1)
Kv = 1;
%Mass of Crystal
%m(4) is moment 3
%MT = Density*Kv*m(4);
global MT
%Rate of Nucleation
%Kb.C(Sat)^B.MT^J
Kb = 3.1512*10.^13*exp(-(78.752)/(0.008314*T));
N = Kb*CC.^b*MT.^Z;
%Growth Order
g = 1 ;
%Rate of Growth
Kg = 2.2439*10^6*exp(-(46.550)/(0.008314*T));
G = Kg*CC.^g;
dmdt (1,1) = N;
% in this case m(1) is moment 0
dmdt(1,2) = m(1)*G;
% m(2) is moment 1
dmdt(1,3) = 2*m(2)*G;
% m(3) is moment 2
dmdt(1,4) = 3*m(3)*G;
% m(4) is moment 3
%Initial Value
%y0 [0 0 0 0]de
%solve ode 45
end
Réponses (1)
Adam
le 3 Mar 2017
0 votes
It depends what you intended as to how to fix it. Use a cell array if you really want to store everything that is returned. Your predeclaration suggests you expect 4 numeric results in your dmdt array though.
Basically T is a vector, Brix is a function of t, CS is a function of Brix, CC is a function of CS and N is a function of CC.
Without running your code I can't easily tell if there are matrix multiplications there which you would expect to reduce the dimensionality back down to being a scalar, but assuming not then N will be a vector of the same size T was so you cannot assign it to dmdt(1,1) which is, of course a single scalar element of a matrix.
1 commentaire
Joshua Ong
le 3 Mar 2017
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!