Clear Filters
Clear Filters

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

9 views (last 30 days)
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.

Accepted Answer

KSSV
KSSV on 20 Oct 2017
Edited: KSSV on 20 Oct 2017
Let a be your column matrix.
b = -a ;
Note that
-1X-1 = +1
-1X+1 = -1

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!