Operations depending on the row/column

I have a 339x339 matrix (f2) containing values and I need to multiply all the cells below row 170 and columns less than 170 by -1. Below is what I have so far.
for t=1:339
if t < 170
f2=f2*-1;
end
end
This just makes everything negative.
Thank you for your help!

 採用された回答

madhan ravi
madhan ravi 2020 年 6 月 30 日
編集済み: madhan ravi 2020 年 6 月 30 日

0 投票

f2(1:169,:) = -f2(1:169,:)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2019a

質問済み:

2020 年 6 月 30 日

編集済み:

2020 年 6 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by