create "for" condition to multiply specific values of a column
1 回表示 (過去 30 日間)
古いコメントを表示
Augusto Gabriel da Costa Pereira
2022 年 12 月 29 日
コメント済み: Augusto Gabriel da Costa Pereira
2022 年 12 月 29 日
I have these values in an attached matrix called "belem_gldas.mat"
I want to make the following condition: for values less than 1 of all rows in column 6 perform the multiplication by "dia_28"
In short:
I want to multiply all values <1 for all rows in column 6 by "day_28"
dia_28=2419200
for belem_gldas=belem_gldas(belem_gldas(:,6)<1,:)
belem_gldas(:,6)<1*dia_28
end
0 件のコメント
採用された回答
Image Analyst
2022 年 12 月 29 日
Try this:
% Get data.
s = load('belem_gldas.mat')
belem_gldas = s.belem_gldas
dia_28=2419200;
% Get mask = rows where column 6 is less than 1.
mask = belem_gldas(:, 6) < 1;
% For those rows only, multiply the values by dia_28.
belem_gldas(mask, 6) = belem_gldas(mask, 6) * dia_28
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Author Block Masks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!