How to assign value in an array depending on the index stated in another array
Afficher commentaires plus anciens
Hi
I have an array of size 11x2 where the first column is the index value and the second is the value. I would like to create another array of size 24x1 where the values of the indexs mentioned in the first array are one I tried the following but it did not owrk :
schedule= (zeros(size(24)))
schedule(lowestpricesgrid(:,1))=1
The lowest prices grid contains the following values:
index value
6 39
7 40
5 40
4 40
8 41
3 42
2 44
14 44
9 44
10 45
13 45
The code above returns a array of size 1x14 : 0 1 1 1 1 1 1 1 1 1 0 0 1 1
I would like it to ideally be : 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0
Thank you for the help!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!