Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-1-by-2.
3 views (last 30 days)
KIPROTICH KOSGEY on 16 Apr 2021
I keep getting the above error when i run the below code. I have no clue on how to fix it. Its is pretty short code.
If anyone can assist, i will appreciate.
mo=4*10^-11; %initial particle mass in gCOD
Mx=7.2*10^-11; %maximum particle biomass
rho=32000; %maximum density of particles in gCOD/cubic metre of particles
x1(1,1,1)=k;%initial pos AOB
x2=x1+1*10^-6; %initial pos Nitrobacter
x3=x2+1*10^-6; %initial pos Nitrospira
x4=x3+1*10^-6; %initial pos CMX
x5=x4+1*10^-6; %initial pos AMX
x6=x5+1*10^-6; %initial pos het
Daniel Pollard on 16 Apr 2021
I haven't run it, but I think your code will error on the line
because deltaxj(i,ii,iii) is a number, so has one element, and dn is an array which grows with every iteration. You can't assign an array element to be equal to an array.
I suspect you intended
As a side note, please choose better names for your loop indices. Firstly, i is a bad variable name because it already has a built-in value, and secondly, it's difficult to tell at a glance what the difference between (ii,iii) and (iii,i) is (for example). If you really need to use that many nested loops (rather than vectorising your code), I'd suggest using k1, k2, k3, or similar.