Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Axel Yantosca
Axel Yantosca am 22 Okt. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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)

Antworten (2)

Ameer Hamza
Ameer Hamza am 22 Okt. 2020
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 am 22 Okt. 2020
ismember(x, Bingo_card)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by