create "for" condition to multiply specific values ​​of a column

3 次查看(过去 30 天)
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

采纳的回答

Image Analyst
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 CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by