Containg the especific number in the vector

1 回表示 (過去 30 日間)
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 2 月 7 日
Hi MATLAB Community,
I would to ask a help please,
my purpose in the follow code is counting, how many number greater 1 or equal (x>=1), and put in a variable the number of values greater 1.
The code are as follows:
Which is my mistake in the code?
Error message :
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error.
To construct matrices, use brackets instead of parentheses.
Thank you very much for attention
Guilherme Lopes
b = linspace(0,5,20);
n=0;
m=0;
for b = 1:n
if b(1,:n)>=0
n = n+1;
else
m=m+1;
end
end
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 2 月 7 日
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 2 月 7 日
Thank you very much KALYAN!!

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2019 年 2 月 7 日
No loops needed:
numbers_greater_than_one_or_equal = nnz(b>=1)
numbers_lesser_than_one = nnz(b<1)
  3 件のコメント
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 2 月 7 日
Perfectly Madhan,
it works!!!
Thank you very much for attention.
Very grateful
Guilherme Lopes de Campos
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 2 月 7 日
Thank you KALYAN , for to show how to write the code with the knowledge previous.
'-'

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by