# Thread: Find max in a column of a matrix for antidiagonal help

1. ## Find max in a column of a matrix for antidiagonal help

this is how i have managed to get a user to input a matrix

Code:
clear all
disp('Input size of matrix you would like to create (NxN)')
N=input('N=');
for i=1:N
for j=1:N
a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
end
end
disp('Matrix before modification')
a
i=1
j=1
a(i,j)=Max;
Nmax=1,1;
for i=1
for j=1:N
if a(i,j)>Max
Max=a(i,j);
Nmax=i,j;
end
if a(Nmax)=Max
a(i,j)=zeros
end
end
k=(j+1)
i=(i+1);
end
[/SIZE][/FONT]i would like to know how to find out if the antidiagonal of each column is tha maximum of that column and then be able to set a condition if the result is true

i have edited the code abit more but its not workign and i dont know how to fix it or if im even goign about it the right way

2. Code:
clear all
disp('Input size of matrix you would like to create (NxN)')
N=input('N=');
for i=1:N
for j=1:N
a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
end
end
disp('Matrix before modification')
a
i=1;
j=1;
a(i,j)=Max; %Where is Max defined
Nmax=1,1;
for i=1       %What range do you expect here?
for j=1:N
if a(i,j)>Max  %Where is Max defined
Max=a(i,j);
Nmax=i,j;
end
if a(Nmax)==Max
a(i,j)=zeros; %what does zeros do without argumants?
end
end
k=(j+1)  %what do you think j is at this point N?
i=(i+1);
end

3. Originally Posted by CaptainBlack
Code:
clear all
disp('Input size of matrix you would like to create (NxN)')
N=input('N=');
for i=1:N
for j=1:N
a(i,j)=input(strcat('a(',int2str(i),',',int2str(j),')='));
end
end
disp('Matrix before modification')
a
i=1;
j=1;
a(i,j)=Max; %Where is Max defined
Nmax=1,1;
for i=1       %What range do you expect here?
for j=1:N
if a(i,j)>Max  %Where is Max defined
Max=a(i,j);
Nmax=i,j;
end
if a(Nmax)==Max
a(i,j)=zeros; %what does zeros do without argumants?
end
end
k=(j+1)  %what do you think j is at this point N?
i=(i+1);
end
sorry, my code is not very clear, i want to be able to check each column of the matrix and if the biggest number in the column happens to eb on the antidiagonal that particular column will be turned to zeros,
if im goign to be honest my tutor wrote a bit of the code fro me and im clueless as to what is going on. thanks