I've got a matrix with 4 columns and I want to insert a fifth one and I want it to have either -1,1 or 0 depending on the results of the subtraction of the values from my colums 3 and 2.
Show older comments
354.0000 0.8058 0.0745 -0.7312
356.0000 0.8077 0.2874 -0.5203
358.0000 0.9386 0.2128 -0.7258
360.0000 0.8834 0.1159 -0.7676
362.0000 0.8750 0.2302 -0.6448
364.0000 0.5578 0.0079 -0.5499
366.0000 0.6020 0.4472 -0.1548
368.0000 0.5581 0.3495 -0.2086
For example, I subtracted the values from column 3 and 2 and added the results as a 4th column. Now I want to add a fifth column whose values will be either 1, -1 or 0 depending on the subtraction results of the values from column 3 and 2. I want my 5th column to show 1, when the C3>C2 ; -1 when the C3<C2 and 0 when the C3=C2 and I want to do it for each row in column 5.
2 Comments
Efraim Culfa
on 7 Oct 2015
Edited: Efraim Culfa
on 7 Oct 2015
Thorsten
on 7 Oct 2015
Just run the code once ;-)
Accepted Answer
More Answers (0)
Categories
Find more on Functions 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!