How I can create this matrix with this logical operation?

1 回表示 (過去 30 日間)
Sourasis Chattopadhyay
Sourasis Chattopadhyay 2021 年 8 月 4 日
回答済み: Awais Saeed 2021 年 8 月 4 日

採用された回答

Awais Saeed
Awais Saeed 2021 年 8 月 4 日
I would do this like
matA = [1 7000; 1.05 6500; 1.05 6800; 1.12 6400; 1.34 6700];
simdone = 1;
row = 1;
while (simdone == 1)
if ((matA(row+1,1) > matA(row,1)) && (matA(row,2) > matA(row+1,2) ))
row = row + 1;
else
matA(row+1,:) = []; % delete row if condition does not match
end
if (row == size(matA,1))
simdone = 0; % break the while loop if index is out of bound
end
end
disp(matA)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by