How to assign values in 3D matric bed on indexing of other matrix?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to assign values to meshpoints from samplepoints and I have 3 matrix. 1st is collection of data from samplepoints (Timeseries) = 334x49792, 2nd has index column numbers for mesh from the nearest values of Timeseries 3rd is CP where values should be stored from Timeseries. Now, I want to assign values of Timeseries to meshpoints based on each values of IDX and these values represent the column number of Timeseries.
Timeseries values (49792x334)
-620 -673 -251 -224 -2 -93 -8 -49....
-647 -615 -282 -190 -79 -54 -59 -22...
-594 -553 -167 -151 -175 -31 -71 -24...
-547 -527 -179 -120 -233 -47 -46 -53...
-506 -544 -151 -99 -163 -97 -46 -5...
-498 -547 -23 -32 -44 -137 -59 -19...
IDX (in this matrix column numbers are given of Timeseries from which values Timeseries should be assigned in CP
IDX(81x126) These values are actually column numbers of time series.
1 1 1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2
29 29 29 29 29 29 29 30 30 30 30 30
29 29 29 29 29 29 29 30 30 30 30 30
29 29 29 29 29 29 29 30 30 30 30 30
CP (81x126x49792)
-620 -620 -620 -620 -620 -620 -620 -673 -673 -673 -673 -673 (values from column 1 & 2 of Timeseries - only 1st row values)
-620 -620 -620 -620 -620 -620 -620 -673 -673 -673 -673 -673 (values from column 1 & 2 of Timeseries - only 1st row values)
-620 -620 -620 -620 -620 -620 -620 -673 -673 -673 -673 -673 (values from column 1 & 2 of Timeseries - only 1st row values)
-620 -620 -620 -620 -620 -620 -620 -673 -673 -673 -673 -673 (values from column 1 & 2 of Timeseries - only 1st row values)
-420 -420 -420 -420 -420 -420 -420 -771 -771 -771 -771 -771 (values from column 29 & 30 of Timeseries - only 1st row values)
-420 -420 -420 -420 -420 -420 -420 -771 -771 -771 -771 -771 (values from column 29 & 30 of Timeseries - only 1st row values)
-420 -420 -420 -420 -420 -420 -420 -771 -771 -771 -771 -771 (values from column 29 & 30 of Timeseries - only 1st row values)
-420 -420 -420 -420 -420 -420 -420 -771 -771 -771 -771 -771 (values from column 29 & 30 of Timeseries - only 1st row values)
How to code this?
0 个评论
回答(1 个)
Varun
2023-3-21
Hello,
I think you just need to use the index values present in ‘IDX’ and get values from ‘samplepoints’ and then, reshape the array to get the required dimensions.
CP=samplepoints(:,IDX);
% samplepoints is the timeseries array
[r,c] = size(IDX);
[z, ~] = size(samplepoints);
CP = reshape(CP',[r,c,z]);
Hope this helps!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!