Clear Filters
Clear Filters

How do I alternate the sign in an 1*n array?

2 views (last 30 days)
For example: turn A= [ 12, 1, 10, 33] into B = [12, -1, 10, -33] Thanks for sparing time for a beginner

Accepted Answer

Matt J
Matt J on 26 Jan 2014
B=A;
B(2:2:end)=-B(2:2:end);

More Answers (0)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!