ベクトル b にあるスカラ値 a が含まれていれば出力として 1 を返し、含まれていなければ 0 を返すような関数を作成しましょう。
例:
a = 3; b = [1,2,4];
スカラ値 3 はベクトル b に含まれていないので、関数は 0 を返します。
a = 3; b = [1,2,3];
スカラ値 3 はベクトル b に含まれているので、関数は 1 を返します。
- (英語版) Problem 838. Check if number exists in vector https://www.mathworks.com/matlabcentral/cody/problems/838
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers344
Suggested Problems
-
7883 Solvers
-
The Hitchhiker's Guide to MATLAB
3422 Solvers
-
Calculate the area of a triangle between three points
3539 Solvers
-
Create an index-powered vector
963 Solvers
-
Convert a Cell Array into an Array
2321 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!