フィルターのクリア

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 Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by