Azzera filtri
Azzera filtri

How to assign negative and positive values to specific numbers in array?

9 visualizzazioni (ultimi 30 giorni)
How would I flip the signs in the array? a = xp', where 'a' is the array.
ans =
0.0581
0.0562
0.0544
0.0525
0.0506
0.0488
0.0469
0.0450
0.0431
0.0412
0.0394
0.0375
0.0356
0.0338
0.0319
0.0300
0.0281
0.0262
0.0244
0.0225
0.0206
0.0188
0.0169
0.0150
0.0131
0.0112
0.0094
0.0075
0.0056
0.0038
0.0019
0
-0.0019
-0.0038
-0.0056
-0.0075
-0.0094
-0.0112
-0.0131
-0.0150
-0.0169
-0.0188
-0.0206
-0.0225
-0.0244
-0.0262
-0.0281
-0.0300
-0.0319
-0.0338
-0.0356
-0.0375
-0.0394
-0.0412
-0.0431
-0.0450
-0.0469
-0.0488
-0.0506
-0.0525
-0.0544
-0.0562
-0.0581
-0.0600
I need all negative numbers to be positive and all positive numbers to be negative. Sign needs to flip after the zero in the middle of the array.

Risposta accettata

KSSV
KSSV il 20 Ott 2017
Modificato: KSSV il 20 Ott 2017
Let a be your column matrix.
b = -a ;
Note that
-1X-1 = +1
-1X+1 = -1

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by