Use array values as assignment indecis
Ältere Kommentare anzeigen
A = N-by-2 array, wherein A(:,1)<A(:,2)
B = M-by-2 array, wherein B(:,1)<B(:,2)
A and B are essentially time stamps.
C = unique(vertcat(A,B));
[~,D] = ismember(A,C);
[~,E] = ismember(B,C);
C([D(1,1):D(1,2),...D(N,1):D(N,2)],2) = any scalar, or an array with a sufficient number of elements to dstribute.
C([E(1,1):E(1,2),...E(N,1):E(N,2)],3) = any scalar, or an array with a sufficient number of elements to dstribute.
I'm hung up on defining those assignment indecis [D(1,1):D(1,2),...D(N,1):D(N,2)] without using a loop, i.e.
IdcsD = double.empty;
for i=1:size(D,1)
Idcs = [Idcs,[D(i,1):D(i,2)]];
end
C(IdcsD) = Value;
3 Kommentare
Matt J
am 23 Nov. 2022
What is the size of D and what is the size of 'Value'?
Matt J
am 23 Nov. 2022
Please show an example for small N and showing the desired output D.
Gabriel Stanley
am 23 Nov. 2022
Bearbeitet: Gabriel Stanley
am 23 Nov. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!