How to obtain a particular value from set of matrix
2 views (last 30 days)
Show older comments
I have a workspace with set of 40 matirx 131X160. I want to get the value of (59,127) in a form of single matrix (1X41) named new from all the matrix in one run. I have script defining all the matrices in the name Freq1Hz.
I used the below code but I couldnt get in the form of single matrix.
for i = 1:41
New = Freq1Hz(59,127,i)
end.
0 Comments
Answers (1)
Star Strider
on 27 Sep 2021
If they are not already in some sort of array themselves, it would first be necessary to put them in one. Then extracting the element you want from each one is straightforward —
M1 = randn(131,160);
M2 = randn(131,160);
M3 = randn(131,160);
M4 = randn(131,160);
Mcat = cat(3,M1,M2,M3,M4);
CheckSize = size(Mcat) % Optional
Freq1Hz = squeeze(Mcat(59,127,:))
If they are in a cell array or are already concatenated (such as I do here), that would make this easier.
.
0 Comments
See Also
Categories
Find more on Operators and Elementary Operations 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!