on-internet
← Community

How can I plot all the diagonals of a matrix in MATLAB?

Stack Overflow ·

I want to plot all the diagonals of a matrix. In the matrix, row 1 contains information for time 1, row 2 for time 2, etc. Each diagonal represents the evolution of the number of fish in a cohort that appeared at a given point in time. Is there a built-in function in MATLAB for this problem? This is the smartest code I could think of, but I am missing some lines: close clear clc %A=[10 20 30 45 55;11 22 30 44 51; 10 20 30 40 50; 10 20 35 40 48]; A=[1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5] r=size(A,1); c=size(A,2); p=c-r+1;%number of diagonals T=size(diag(A),1);%T=min(S,N) x=linspace(1,T,T);

Comments

Sign in or sign up to comment and upvote.

No comments yet.