Indexing and replacing value in a zero matrix based on a table
Show older comments
Hello,
I am trying to input a value in a zeros matrix of size 11*10. This is based on a variable which has three columns (Number, ID, ANS) as shown below. Now I want to insert the value in ANS which is -1 in the zeros matrix at 10x5 (ID x Number) position (index). Any suggestion on how this can be done?
Number ID ANS
5 10 -1
Accepted Answer
More Answers (1)
Arvind Sathyanarayanan
on 19 Dec 2018
Is this what you're looking for?
ID = 10; Number = 5; Ans = -1;
tmat = zeros(11,10);
tmat(ID,Number)=Ans;
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!