convert an array value into corresponding Matrix indices
古いコメントを表示
Given an array of values, I would like to place a "1" into the corresponding Matrix element

I'm currently doing...
matrix = zeros( numDatapoints,10 ); %Start with a zero matrix of correct size
for row = 1:numDatapoints
for i = 1:10
if dataArray(row,17) == i %compare the value of the array to the current index
matrix(row,i) = 1;
end
end
Any suggestions to improve this in MATLAB?
1 件のコメント
Matt J
2022 年 3 月 23 日
corresponding to what?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!