Plotting matrices and generating random integers - MATLAB

I was interested in plotting a matrix vs matrix in MATLAB. At first, I though that using plot(matrix1, matrix2) would plot each row from each matrix against each other. I then tried using a for loop where I looped over each row in order to plot all rows(also had to use "hold on"). I learned my lesson when I looked at documentation for plot(), which stated that when plotting matrices, the columns of each matrix were plotted against each other. So I had to use plot(matrix1', matrix2'). 

I also had was interested in plotting random rows from the matrices, rather than all of the data from the matrices. I found that randi() would allow me to achieve this, as it can generate a vector of random integers given a specific range. Then I could just use plot(matrix1(genvector, :), matrix2(genvector, :)) to obtain the plot with random rows from each of the matrices. 

It was nice getting back into MATLAB after some time. I hope to continue practicing MATLAB, in addition to Python, as it will be useful for plotting figures for research during graduate school. 

Comments

Popular posts from this blog

subplot() vs tiledlayout() - MATLAB

Modifying PDF contrast with Inkscape

Making a website with a blog? Not sure yet