I have a 2D matrix, say A=zeros(10,10). I want to add a vector of number to the matrix. I have the index of the elements, but it is repeated. E.g. the index [5,3,2,5,3,100,5] and the value is some random [1,2,3,4,5,6,7]. I then want to add 1 into 5th element of A, 2 into 3rd element and so on. How do I do this in one line?
4 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461603
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461603
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461609
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461609
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461612
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461612
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461614
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/344712-add-element-to-the-matrix-in-one-sentence#comment_461614
Sign in to comment.