I figured out what my issue was. I was looking at the wrong key. When I do M(char(uniqueTimeStamps(i))), it did not mean M('1') but rather M(''). Everything works now.
How do I write to a map of matrices?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
John Alexiades
le 26 Déc 2018
Réponse apportée : John Alexiades
le 26 Déc 2018
So I am using the Map Container in MATLAB to store a matrix for keys of a specific character. The first thing I do is create the mappings and allocate space by doing:
for i=1:uniqueTimeStampsCount
M(char(uniqueTimeStamps(i)))=zeros(uint8(max(y)+1),uint8(max(x)+1));
end
This part works fine as uniqueTimeStamps is just an array of numbers that I convert to chars. So for instance M('1') would map to a matrix of all zeros.
My issue is the next part where I want to go through a list of keys to access and modify the contents of the respective matrices:
for i=1:size(TimeStamp,1)
temp = M(char(TimeStamp(i)));
temp(y(i)+1,x(i)+1)= polarity(i);
M(char(TimeStamp(i))) = temp;
end
The first part of this works where I store the value into temp and modify a specific (x,y) coordinate in that matrices. The issue is writing back to the map container. I am not sure why the line M(char(TimeStamp(i))) = temp; is not updating the mapping with the temp matrix.
Any advice is greatly appreciated.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!