How do I write to a map of matrices?

1 visualización (últimos 30 días)
John Alexiades
John Alexiades el 26 de Dic. de 2018
Respondida: John Alexiades el 26 de Dic. de 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.

Respuesta aceptada

John Alexiades
John Alexiades el 26 de Dic. de 2018
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.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by