Vertical dimensions mismatch in matrix
3 views (last 30 days)
Show older comments
Diptangshu Sen
on 15 Sep 2018
Edited: Walter Roberson
on 16 Sep 2018
I wrote the following code:
function checktransition(k,l,day)
global Town;
global infection_stage;
global f1;
global f2;
# 11 X 11 Matrix
# AI,F0,F1,F2,F3,F4,R,DC,HCC,LT,LRD
if infection_stage(k,l)==360
if (Town(k,l)==9) f1 = 0.147;
elseif (Town(k,l)==11) f2 = 0.08;
endif
elseif infection_stage(k,l)>360
if (Town(k,l)==9) f1 = 0.182;
elseif (Town(k,l)==11) f2 = 0.044;
endif
endif
d1 = 0.909 -f1;
d2 = 0.977 -f1;
d3 = 1 -f1;
d4 = 1-f2;
TPM = [0 0.4 0 0 0 0 1 1 1 1 1]; #AI
TPM = [TPM; 0 0.883 1 1 1 1 1 1 1 1 1]; #F0
TPM = [TPM; 0 0 0.915 1 1 1 1 1 1 1 1]; #F1
TPM = [TPM; 0 0 0 0.88 1 1 1 1 1 1 1]; #F2
TPM = [TPM; 0 0 0 0 0.804 0.920 0.920 0.920 1 1 1]; #F3
TPM = [TPM; 0 0 0 0 0 0.947 0.947 0.986 1 1 1]; #F4
TPM = [TPM; 0.01 0.01 0.01 0.01 0.01 0.01 1 1 1 1 1]; #R
TPM = [TPM; 0 0 0 0 0 0 0 d1 d2 d3 1]; #DC
TPM = [TPM; 0 0 0 0 0 0 0 0 0.533 0.577 1]; #HCC
TPM = [TPM; 0 0 0 0 0 0 0 0 0 d4 1]; #LT
TPM = [TPM; 0 0 0 0 0 0 0 0 0 0 1]; #LRD
Some more code
endfunction
I get the following error:
Vertical dimensions match 7X11 vs 1X8 from the 8th line in the matrix.
But, all dimensions are correct. what is the issue and how to resolve it?
1 Comment
Walter Roberson
on 16 Sep 2018
This is not MATLAB code. Octave support is through the mailing list help@octave.org or through the commercial support at https://www.gnu.org/software/octave/commercial-support.html; you could probably also get support through stackoverflow
Accepted Answer
Walter Roberson
on 16 Sep 2018
Edited: Walter Roberson
on 16 Sep 2018
If we were to make guesses about what some of those non-MATLAB constructs mean, then your problem is that the infection stages at the chosen k, l is less than 360 or else Town(k,l) is not either 9 or 11; and the global variable f1 has not been initialized by you. Under that combination of conditions, f1 would be [] and then
d1 = 0.909 -f1;
d2 = 0.977 -f1;
d3 = 1 -f1;
would all get assigned []. Then the line
TPM = [TPM; 0 0 0 0 0 0 0 d1 d2 d3 1]; #DC
would be the same as if it had been
TPM = [TPM; 0 0 0 0 0 0 0 1]; #DC
which is a size mismatch with the rest of TPM.
However, you would need to consult an Octave resource to find out what Octave does with global variables you do not assign a value to.
0 Comments
More Answers (0)
See Also
Categories
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!