How to assign values in 3D matric bed on indexing of other matrix?

조회 수: 1 (최근 30일)
Jigar
Jigar 2022년 12월 11일
댓글: Jigar 2023년 3월 21일
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?

답변 (1개)

Varun
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 CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by