필터 지우기
필터 지우기

If else condition to set values greater or equal to one

조회 수: 2 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2023년 11월 2일
댓글: Turbulence Analysis 2023년 11월 2일
Hi,
I am multiplying values in the one column with other one, lets say B = A(:,1).* A(:,2)
Here before performing the multiplication, if the values in the both the columns falls bettwen -0.02 to 0.02 this needs to be set to 1. I tried with if else, but not getting the desired results.

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 2일
편집: Dyuman Joshi 2023년 11월 2일
%Comparison of rows to find which rows have both values
%in the range [-0.02, 0.02]
idx = all(abs(A(:,1:2)) <= 0.02, 2)
%Replace the values
A(idx, 1:2) = 1

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by