Marking indexes
1 回表示 (過去 30 日間)
古いコメントを表示
x=[1 7 12 16];
y=zeros(1,20);
I want to show 1 in y at x valued indices.. i.e,
y(1)=1
y(7)=1
y(12)=1
y(16)=1
y(for all)=0
how I can stem it automatically without manually zero padding ?
0 件のコメント
採用された回答
Laura Proctor
2011 年 4 月 19 日
I think that all you want to do is this:
x = [ 1 7 12 16 ];
y = zeros(1,20);
y(x) = 1
y = sparse(1,20);
y(x) = 1
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!