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

1 Ansicht (letzte 30 Tage)
Jigar
Jigar am 11 Dez. 2022
Kommentiert: Jigar am 21 Mär. 2023
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?

Antworten (1)

Varun
Varun am 21 Mär. 2023
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!

Kategorien

Mehr zu Time Series finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by