Adding Scaler to Matrix Problem

3 次查看(过去 30 天)
JASON REESE
JASON REESE 2019-9-26
编辑: Adam 2019-9-26
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 个评论
Adam
Adam 2019-9-26
编辑:Adam 2019-9-26
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by