MATLAB Answers

0

Adding Scaler to Matrix Problem

Asked by JASON REESE on 26 Sep 2019
Latest activity Edited by Adam
on 26 Sep 2019
nodeTimeMatrix is a 7 X 10000 matrix.
I am imbedding the below in an if statement, and if the if statement is true I am trying to add the scaler "adjustment" to a specific row and column of nodeTimeMatrix. The below to me makes sense, but for some reason I am getting a size mismatch error from Matlab. Any help on this is appreciated.
the code that is failing is:
nodeTimeMatrix(i,i2) = nodeTimeMatrix(i,i2) + adjustment;
the error I am getting is:
"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-10000."
Not sure why this is happening since the left and right side are literally the same matrix...

  1 Comment

Adam
on 26 Sep 2019
nodeTimeMatrix(i,i2) is a scalar, assuming i and i2 are scalars then this just indexes into a single location of a 2d matrix. I would guess that adjustment is in fact a 1-by-10000.
This can be checked easily simply by debugging and looking in the workspace in a breakpoint there.
nodeTimeMatrix(i,:) = nodeTimeMatrix(i,:) + adjustment;
may be what you want, at a guess.

Sign in to comment.

0 Answers