필터 지우기
필터 지우기

Adding to variable dependant on condition

조회 수: 4 (최근 30일)
Holden Earl
Holden Earl 2020년 4월 14일
편집: Tommy 2020년 6월 30일
i have a table and am checking if values lie within this range 60<=a<70, if they do i want to add 1 to another variable "x" so that x will represent the number of values within this range. using an elseif function how would i do this, thanks!
for a = 1:length(x)
if a >= 60 && a <70
  댓글 수: 6
Walter Roberson
Walter Roberson 2020년 4월 14일
You are calculating x+1 and throwing the result away instead of recording the result of the addition.
If a is the vector of values to be checked, you should probably not be using for a . You should probably be using an index into a, like for idx = 1 : length(a) and checking the value of a indexed at that variable.
Holden Earl
Holden Earl 2020년 4월 14일
thats got it, thanks guys!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by