Reconstruct a compressed vector based on another one with equal space entities

조회 수: 3 (최근 30일)
Hi,
assuming I have a Vector of Values and a corresponding Position Vector with constant steps of 250:
VaVector(1,20,-4,23,NaN,NaN,NaN,6,3,NaN,7,-23);
PosVector(2000,2250,2500,2750,3000,3250,3500,3750,4000,4250,4500,4750);
However I have the compressed Vectors with deleted NAN, so I have
VaVector_comp(1,20,-4,23,6,3,7,-23);
PosVector_comp(2000,2250,2500,2750,3750,4000,4500,4750);
How can I reconstruct the VaVector & PosVector? Please note, my example here contains only 12 Values, for simplification (my real compressed Vector contains >5000)
Thank you
Chris

채택된 답변

Stephen23
Stephen23 2025년 3월 5일
VC = [1,20,-4,23,6,3,7,-23]
VC = 1×8
1 20 -4 23 6 3 7 -23
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
PC = [2000,2250,2500,2750,3750,4000,4500,4750]
PC = 1×8
2000 2250 2500 2750 3750 4000 4500 4750
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
PV = PC(1):250:PC(end)
PV = 1×12
2000 2250 2500 2750 3000 3250 3500 3750 4000 4250 4500 4750
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
VV = nan(1,numel(PV));
VV(ismember(PV,PC)) = VC
VV = 1×12
1 20 -4 23 NaN NaN NaN 6 3 NaN 7 -23
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by