Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Form a matrix from elements of a second matrix

2 Ansichten (letzte 30 Tage)
Shashank
Shashank am 22 Okt. 2012
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Suppose if I have a matrix like this:
Time = [1;2;3;4;5;6;7;8;9;10]
Diameter = [1;2;3;4;5;6;7;8;9;10]
If I want to form two matrices, one for diameters less than 6 and other for diameters greater than 6, how can I do that? I also need times for the corresponding diameters on each matrix.
Thanks.

Antworten (1)

Matt Fig
Matt Fig am 23 Okt. 2012
Bearbeitet: Matt Fig am 23 Okt. 2012
Your question is a little unclear, but I think you can get what you want with logical indexing.
idx = Diameter<6; % A logical index.
D1 = Diameter(idx);
T1 = Time(idx);
D2 = Diameter(~idx);
T2 = Time(~idx);

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by