Effacer les filtres
Effacer les filtres

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

9 vues (au cours des 30 derniers jours)
Zach Dunagan
Zach Dunagan le 20 Oct 2017
Commenté : Zach Dunagan le 20 Oct 2017
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.

Réponse acceptée

KSSV
KSSV le 20 Oct 2017
Modifié(e) : KSSV le 20 Oct 2017
Let a be your column matrix.
b = -a ;
Note that
-1X-1 = +1
-1X+1 = -1

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by