Filter löschen
Filter löschen

How do I replace multiples of 4 with a 0 in a magic 4 matrix?

2 Ansichten (letzte 30 Tage)
Noah Franks
Noah Franks am 22 Okt. 2019
Kommentiert: Noah Franks am 23 Okt. 2019
I have googled and tried and done everything I can think of and still can't get this to work. Can someone please help me?
  1 Kommentar
Noah Franks
Noah Franks am 22 Okt. 2019
%Solution to P6
disp ('P-6');
res=0;
A=magic(4);
for row=1:4
for col=1:4
if A(mod(A,4)==0)==0
res=mat;
end
end
end
disp(res);
This is my code.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

David Hill
David Hill am 22 Okt. 2019
a=magic(4);
a(mod(a,4)==0)=0;

Noah Franks
Noah Franks am 22 Okt. 2019
To the two gentleman who answered my question, it didn't work.
  1 Kommentar
David Hill
David Hill am 22 Okt. 2019
You need to explain more; because based on your description, the answer works perfectly.

Melden Sie sich an, um zu kommentieren.


Cre'Shawn Dabney
Cre'Shawn Dabney am 23 Okt. 2019
Hey Noah this should be the code. Just incase you didnt get it yet.
disp('P-6');
res=0;
a=0;
for row=1:4
for col=1:4
if mat==mat
a=magic(4);
a(mod(a,4)==0)=0;
end
end
end
disp(a);
  1 Kommentar
Noah Franks
Noah Franks am 23 Okt. 2019
This worked perfectly! Thank you SO much! I spent hours over that one area.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by