フィルターのクリア

How to find maximum square zero matrix through the biggest matrix?

2 ビュー (過去 30 日間)
Serafettin Bal
Serafettin Bal 2021 年 6 月 17 日
コメント済み: Atsushi Ueno 2021 年 6 月 22 日
how to plot a picture in matlab?
Below is the code that generates a random 6*6 diagonal square matrix.
And, the resulting random matrix (Mout) is ​​here.
For example, the largest square zero matrix for this matrix is ​​as follows.
4*4 Square zero matrix for the 6*6 square matrix.
So, how can I find the size of the maximum square zero matrix that can be created from this matrix?
  7 件のコメント
Rik
Rik 2021 年 6 月 22 日
編集済み: Rik 2021 年 6 月 22 日
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
There is also now a capture of the current state of this thread.
The image of the code was later replaced by this:
N = randi([6 6],1);
M = randi([0 1], N);
Mu = triu(M);
Ml = Mu';
Mout = Mu + Ml;
Mout = Mout - diag(diag(Mout));
G = graph(Mout,'lower');
plot(G)
Atsushi Ueno
Atsushi Ueno 2021 年 6 月 22 日
@Rik Thank you for your recovering action. I can read back the comment left by the questioner in the history, so I will answer it.

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

採用された回答

Atsushi Ueno
Atsushi Ueno 2021 年 6 月 18 日
What I did is:
If there are square zero matrices of the same size, the upper left one will be selected.
Sorry, it is not tested well.
N = randi([6 6],1);
M = randi([0 1], N);
Mu = triu(M);
Ml = Mu';
Mout = Mu + Ml;
Mout = Mout - diag(diag(Mout));
G = graph(Mout,'lower');
plot(G);
Mout4 = repmat(Mout,2);
for k = 1:length(Mout)
[r,c] = find(~conv2(Mout4,ones(k),'valid'),1);
if r
k % k is the size of the square zero matrix
r % r is the row index of the square zero matrix
c % c is the column index of the square zero matrix
end
end
  2 件のコメント
Atsushi Ueno
Atsushi Ueno 2021 年 6 月 19 日
I'm sorry. I got a lot of questions to answer, but I slept for 12 hours afterwards.
Atsushi Ueno
Atsushi Ueno 2021 年 6 月 22 日
>every runs (because Mout matris created randomly) return the same output. k=1 r=1 c=1 k=2 r=1 c=1
@Serafettin Bal Yes, most of the patters created randomly have small squares. Why don't you create some matrix has bigger chank of zero for testing? The logic I wrote finds the square of zero from smaller one to bigger one. And the last printed out 'k' is the size of the maximum square zero matrix.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by