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

0 Stimmen

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

1 Stimme

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
thanks mate, but not working.
neg_part
is ok, but
pos_part
gives me:
1,18756744635860 1,27884296305101 1,49473255111158 1,84984153587169 2,34531760870569 2,96764547395638 3,68901551096883 4,46925639509316 5,25915173457890 6,00480958865727 6,65263765281459 7,15440856338949 7,47188666387606 7,58053120154209
1,26236627545237 1,35364179214478 1,56953138020536 1,92464036496547 2,42011643779946 3,04244430305015 3,76381434006260 4,54405522418693 5,33395056367267 6,07960841775105 6,72743648190837 7,22920739248326 7,54668549296983 7,65533003063587
1,51401952583936 1,60529504253176 1,82118463059234 2,17629361535245 2,67176968818644 3,29409755343713 4,01546759044958 4,79570847457392 5,58560381405966 6,33126166813803 6,97908973229535 7,48086064287024 7,79833874335681 7,90698328102285
1,89436403494607 1,98563955163848 2,20152913969905 2,55663812445916 3,05211419729316 3,67444206254385 4,39581209955630 5,17605298368063 5,96594832316637 6,71160617724474 7,35943424140206 7,86120515197696 8,17868325246353 8,28732779012956
2,10054963540131 2,19182515209372 2,40771474015429 2,76282372491440 3,25829979774840 3,88062766299909 4,60199770001154 5,38223858413587 6,17213392362161 6,91779177769998 7,56561984185730 8,06739075243220 8,38486885291877 8,49351339058480
instead of this:
1,15485676094973 1,19451815030085 1,20412043363455 1,16897039548394 1,11900221787751 1,07932141846948 1,05306045991812 1,03637554207581 1,02571982389170 1,01883364616317 1,01439082605421 1,01162827719253 1,01011767563388 1,00964189492878
1,23149376578704 1,29087195834602 1,32225831933373 1,29380568524417 1,22661117478516 1,16146387859150 1,11377118354573 1,08191048649584 1,06104931872940 1,04739810325876 1,03853466279094 1,03300587840370 1,02997823192364 1,02902453044548
1,49091401583563 1,60746567066052 1,71123931432361 1,74520929512768 1,68139193321320 1,55973171029638 1,43671295235433 1,33877461070480 1,26827529760834 1,21971859774102 1,18730234541293 1,16677554308228 1,15544859561137 1,15187375450278
1,88335663640220 2,07518125588252 2,27599431090162 2,42140452584105 2,44078079902875 2,32434868034895 2,13399535699737 1,93993783821149 1,77860878301865 1,65777515160354 1,57311700475253 1,51802619627761 1,48718465039155 1,47740611693073
2,09611576761198 2,32652242543890 2,57651406489830 2,78091475505453 2,85678057787953 2,76993046876873 2,56931322938054 2,33680084232103 2,12863552830834 1,96553409962205 1,84812128633599 1,77049431074311 1,72666092137210 1,71272214474297
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.
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

Produkte

Version

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by