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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!