how to find the multiple elements of 5 in a vector ?

2 ビュー (過去 30 日間)
Célia Lejeune
Célia Lejeune 2020 年 3 月 17 日
コメント済み: Célia Lejeune 2020 年 3 月 17 日
hello,
I need to create a vector L=10:1000 and find all the multiple elements of 5 in this vector
I don't know how to proceed.
Could you help me ?

採用された回答

Sriram Tadavarty
Sriram Tadavarty 2020 年 3 月 17 日
Hi Celia,
The following code does this
L = 10:1000; % Created a vector L spanning from 10 to 1000
% To find the multiple elements of 5, you can just span at a difference of 5, since any value having last digit 5 or 0 is divisible by 5
out = 10:5:1000; % This will generate a vector which are divisible by 5
Hope this helps.
Regards,
Sriram
  1 件のコメント
Célia Lejeune
Célia Lejeune 2020 年 3 月 17 日
Thank you a lot, that's what I need

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by