필터 지우기
필터 지우기

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
  댓글 수: 1
Augusto Gabriel da Costa Pereira
Augusto Gabriel da Costa Pereira 2022년 12월 29일
Thanks a lot for the solution. It is an honor to receive a response from you.

댓글을 달려면 로그인하십시오.

추가 답변 (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