Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Finding a value (or not a value) inside a matrix

조회 수: 5 (최근 30일)
Axel Yantosca
Axel Yantosca 2020년 10월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to find a value or if a value is not inside of a matrix. Code so far. Will be using an if statement to do something if condition is met or do nothing if condition is not met.
clc, clear, close all
Bingo_board = randi([1 100],5,5)
x = randi ([1,100], 1)

답변 (2개)

Ameer Hamza
Ameer Hamza 2020년 10월 22일
Try this code
Bingo_board = randi([1 100],5,5)
x = randi ([1,100], 1)
if any(Bingo_board(:)==x)
disp('Match found.');
else
disp('No match found.');
end

Walter Roberson
Walter Roberson 2020년 10월 22일
ismember(x, Bingo_card)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by