2
votes

Plot uses columns to plot a square matrix, but I need it by rows.

plot(matrix(1:end,1:end), 1:columns)

works great when matrix is rectangular (plots each line of matrix with a different color), but when matrix is square is plots by column (as the documentation clearly states) I don't want to break the command to a loop because then I will have to specify the color for each line plot.

Is there a way to change the plot defaults to prefer row in square matrices?

1
how about transposing and plotting? wont it work? plot(matrix.', 1:columns)Santhan Salai
good call, thanks. I was hoping for something I wouldn't have to explain in the code, so I can call it 'self-documented'...EranBD

1 Answers

0
votes

You can use a trick and add a line of NaN at the end of the array:

matrix(end+1,:) = NaN;

And now matrix is rectangular, but the NaN won't be displayed during plot.

Best,