MATLAB Answers

Setting array indices to a vector of values

2 ビュー (過去 30 日間)
David House
David House 2019 年 12 月 13 日
コメント済み: David House 2019 年 12 月 17 日
I am coming from IDL, and in that language I can write something like this:
Temp(xVal, yVal) = VectorOfValues
Where 'Temp' is an array (say 600x300)
xVal = a vector of values that I am using as the x indices
yVal = a vector of values that I am using as the y indices
VectorOfValues = a vector of values the same length as xVal and yVal
Basically I am trying to set the certain indices indicated by xVal and yVal to the values that are in VectorOfValues. I get that I could make a for loop to go through each one but is there another way to do this?

  0 件のコメント

サインイン to comment.

採用された回答

the cyclist
the cyclist 2019 年 12 月 13 日
You can use sub2ind command to convert the subscripted indices (xVal,yVal) into a single linear index into the array.

  1 件のコメント

David House
David House 2019 年 12 月 17 日
Thanks, that worked. An extra line needed compared to IDL but works the same :)

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。


Translated by