필터 지우기
필터 지우기

How to find undefined matrix in a code?

조회 수: 2 (최근 30일)
Cladio Andrea
Cladio Andrea 2015년 3월 3일
댓글: Guillaume 2015년 3월 3일
Hello everyone, i have a matrix that presents the alarmed devices in the coverage of an access point , but i dont have alarmed devices for all access point covarege area, and you know at that time the matrix for alarm is undefined, totally empty matrix so i can't use it in the following steps. What i am asking is : is there any way to write an if statement saying if that matrix is defined do that, if it is undefined do another thing. Can you help me please?

채택된 답변

James Tursa
James Tursa 2015년 3월 3일
If the variable is not defined at all, you can use this:
if( exist('variable_name','var') )
% variable_name is defined
else
% variable_name is not defined
end
If the variable is in fact defined but is actually empty, do this instead:
if( isempty(variable_name) )
% variable_name is empty
else
% variable_name is not empty
end
  댓글 수: 2
Cladio Andrea
Cladio Andrea 2015년 3월 3일
Just perfect , the second one actually is what i want. Thank you so much !!
Guillaume
Guillaume 2015년 3월 3일
In that case, for reference, the matrix is actually defined (i.e. the variable has been declared). The proper term is that it is empty (hence why you use isempty).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix and Vector Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by