make alternate diagonal to zero and etc..

53 views
Skip to first unread message

ro...@igib.in

unread,
Feb 23, 2013, 5:15:10 AM2/23/13
to matlab...@googlegroups.com

more at

---------------------------------------------------------------------------------------------------------------------------------
%----for making second diagonal numbers of matrix equal to zero---

function out=diagonaltozeroplus(in)

r=length(in(:,1));
c=length(in(1,:));
if r==c
out=in;
for countrow=1:r;
for countcol=1:c;
            M=mod(countrow+countcol,2);
            if M==0;
                out(countrow,countcol)=0;
            end
end
    
end

else
    out={'Matrix is not symmetric'};
end
end

---------------------------------------------------------------------------------------------------------------------------------

%-------making a matrix into a single colums vector---------

function out=makeonecolumn(input)

in=length(input(:,1));
jn=length(input(1,:));


for i=1:in;
    for j=1:jn;
            
                out((in*(j-1)+i),1)=input(i,j);
            
    end
end

---------------------------------------------------------------------------------------------------------------------------------


Reply all
Reply to author
Forward
0 new messages