필터 지우기
필터 지우기

Magic square (( please help))

조회 수: 1 (최근 30일)
Melika Eft
Melika Eft 2022년 10월 28일
편집: KALYAN ACHARJYA 2022년 10월 28일
Hi how can I put conditions for magic square such as even or odd or be in MK+1 Form thank you

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 10월 28일
편집: KALYAN ACHARJYA 2022년 10월 28일
result=2*magic(3)
result = 3×3
16 2 12 6 10 14 8 18 4
You have to look for any such possibility for odds too.For any random function or fixed values too, checking data using iteration is not an good idea as per my understanding. Note that magic generates the same values.
Like:
>> data=magic(3)
data =
8 1 6
3 5 7
4 9 2
>> result=double(mod(data,2)==0)+data
result =
9 1 7
3 5 7
5 9 3

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by