Find three in a row

2 ビュー (過去 30 日間)
Nathan Formby
Nathan Formby 2020 年 4 月 23 日
回答済み: Raunak Gupta 2020 年 4 月 30 日
I am creating a randi function that finds three of the same number horizontally, vertically, or diagonally.
But I can't figure out the code to find what I need.
Help?!?!?!
  2 件のコメント
Rik
Rik 2020 年 4 月 23 日
編集済み: Rik 2020 年 4 月 23 日
What have you tried so far? Do you have code that will generate an appropriate array? Do you have any ideas for how to check if any positions satisfy your needs? Bad ideas can be used to find better ideas.
As with your previous question you have forgotten to actually ask a question. Follow the link that was posted there.
Raunak Gupta
Raunak Gupta 2020 年 4 月 28 日
Hi,
Can you share the code you have written so far so that we can help with any error you are getting.

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

回答 (1 件)

Raunak Gupta
Raunak Gupta 2020 年 4 月 30 日
Hi,
You can take a look at Image Analyst Answer for creating a random number generator.
As from the question I assume you are more interested in getting pattern detected in rows, columns and diagonal of a matrix. For that you can check the frequency of each number, rows wise, column wise and on two diagonals of a matrix. You can start with using groupcounts that is mentioned in this answer. From this getting counts for each row can be done by using for loop. After getting group count you can check which number has a frequency of 3 and return it as an answer.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by