How can I change the value of Y in the columns whare the value of X is zero in matrix ?

1 回表示 (過去 30 日間)
I have the large column of matrix XY for example
X Y
1 5
0 10
3 26
0 5
if I want to change the value of Y in the columns whare the value of X is zero like this
X Y
1 5
0 1.5
3 26
0 1.5
Which the command I need to use ?

採用された回答

Alan Stevens
Alan Stevens 2021 年 11 月 4 日
Like this
XY = [1 5
0 10
3 26
0 5];
XY(XY(:,1)==0,2) = 1.5
XY = 4×2
1.0000 5.0000 0 1.5000 3.0000 26.0000 0 1.5000

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by