Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Matthew Worker
Matthew Worker 2017 年 6 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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.
  1 件のコメント
the cyclist
the cyclist 2017 年 6 月 5 日
You haven't been specific enough. For example, would this be OK?
A = rand(5,1);
A(:,2) = A(:,1) - pi;
I expect not.

回答 (1 件)

Image Analyst
Image Analyst 2017 年 6 月 5 日
This will do it (one of an infinite number of ways):
A(:, 2) = A(:, 1) - 1

製品

Community Treasure Hunt

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

Start Hunting!

Translated by