MATLAB Answers

IF-statement for matrix/vector

조회 수: 4(최근 30일)
Talha Demirel
Talha Demirel 15 Jan 2020
답변: WalterWhite 15 Jan 2020
Hi,
I have a 146652x1 matrix (vector) and I want to check each column for a defined condition. For example if the value is greater than 1.
Example:
IF "column_value" > 1
column_value / 0.001
So with this method, I wanto to checkout every single column in my matrix.
How do I code this?

  댓글 수: 0

로그인 to comment.

답변(2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 15 Jan 2020
편집: KALYAN ACHARJYA 15 Jan 2020
As you mentioned that the matrix having size 146652x1, which means it has 1 column. Prefer logical conditional statement.
idx=mat_data>1;
It's return logical data 1, where the value greater than 1, else 0.
Or
If you mat data having multiple columns and rows, force all elements greater than 2 to be Zero
results=mat_data>1 & mat_data
Or
If you wish to check individual cloumn data
for i=1:coumn_num
if mat_data(:,i)>1
% Do
end
end

  댓글 수: 0

로그인 to comment.


WalterWhite
WalterWhite 15 Jan 2020
A sample matlab code in case...

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by