y_vec=zeros(100,10);
% y_vec is initially a zeros matrix. y is a vector of dimension 100 x 1 containing values between 1 and 10. For the value
% at ith row in vector y, y_vec(i,value)=1
for i=1:100
y_vec(i,y(i))=1;
end

답변 (1개)

Rik
Rik 2020년 6월 4일

0 개 추천

You will need to convert to linear indices with sub2ind.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2020년 6월 4일

답변:

Rik
2020년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by