selection of certain data from matrix

1 Ansicht (letzte 30 Tage)
Paul Rogers
Paul Rogers am 14 Jan. 2020
Beantwortet: Paul Rogers am 14 Jan. 2020
Hi, my problem is that I have 3 matrix:
FlowMeasurements, psic_pos_cheb and psic_neg_cheb.
I need a matrix done this way with:
- all the columns of the psic_neg_cheb where FlowMeasurements is negative
- all the columns of the psic_pos_cheb where FlowMeasurements is positive.
For example, in this case it would be a matrix whith the 1-6 colums of psic_neg_cheb,
and after the 7-20 colums of psic_pos_cheb.
The matrixes are in attached

Akzeptierte Antwort

Paul Rogers
Paul Rogers am 14 Jan. 2020
I finally did this way:
for i=1:length(FlowMeasurements)
if FlowMeasurements(i) < 0
CompressorMapMatrix(:,i) = psic_neg_cheb (:,i);
else
CompressorMapMatrix(:,i) = psic_pos_cheb (:,i);
end
end

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 14 Jan. 2020
mask_pos = FlowMeasurements > 0;
mask_neg = FlowMeasurements < 0;
pos_part = psic_neg_cheb(:,mask_pos);
neg_part = psic_neg_cheb(:,mask_neg);
I would often tend to use ~mask_pos instead of constructing an entirely new mask, but ~mask_pos would include <= 0 not just < 0 and that is perhaps not acceptable.
  3 Kommentare
Paul Rogers
Paul Rogers am 14 Jan. 2020
Bearbeitet: Paul Rogers am 14 Jan. 2020
I see, it did't put rows and columns as it should, but it's anyway different values.
Paul Rogers
Paul Rogers am 14 Jan. 2020
the proble is that it takes the first 6 columns of
psic_neg_cheb
which is right, and also the last 14th columns of
psic_neg_cheb
instead of
psic_pos_cheb

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by