Info

This question is closed. Reopen it to edit or answer.

Creating a matrix where the entry in the second column is (weakly) less than the entry in the first column

1 view (last 30 days)
Hello,
I would like to create a matrix where the entry in the second column is less than the entry in the first column:
A
= [ 1 0;
1 1;
2 0;
2 1;
2 2]
I can write loops but I would think there should be more efficient way. Please advise.

Answers (1)

Image Analyst
Image Analyst on 5 Jun 2017
This will do it (one of an infinite number of ways):
A(:, 2) = A(:, 1) - 1

Products

Community Treasure Hunt

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

Start Hunting!