xnxn matrix matlab plot algorithm – Matlab tuto

In this article we discuss xnxn matrix matlab plot algorithm and xnxn matrix matlab code. In other words, we will first see how to create a matrix in matlab. Then we will see how we can create a graph from this matrix. Finally we will discuss some advanced functions with matlab.

Example with 3x3x3 matrix in matlab

First, in this example I am using the rand function to generate decimal values in a 3x3x3 matrix. Then I display it in matlab then I create a graph with the plot 3 function on the 3 dimensions of the example matrix.

>> M = rand(3,3,3)

M(:,:,1) =

    0.8147    0.9134    0.2785
    0.9058    0.6324    0.5469
    0.1270    0.0975    0.9575


M(:,:,2) =

    0.9649    0.9572    0.1419
    0.1576    0.4854    0.4218
    0.9706    0.8003    0.9157


M(:,:,3) =

    0.7922    0.0357    0.6787
    0.9595    0.8491    0.7577
    0.6557    0.9340    0.7431

>> plot3(M(1,:),M(2,:),M(3,:))

In addition, here is a preview of the graph that is created with this:

xnxn matrix matlab plot algorithm
xnxn matrix matlab plot algorithm

Example with 3×3 matrix in matlab with int value

>> M=randi([1,10],3,3)
>> plot(M(1,:),M(2,:))
xnxn matrix matlab code
xnxn matrix matlab code

In this example which is similar to the previous one I use the randi function which allows me to generate integers with matlab in a range given as an argument. In the end I get a 3×3 matrix that I display in the console then I use the plot function.

Here is another result if now I use plot3 function :

>> M=randi([1,10],3,3)
>> plot3(M(1,:),M(2,:),M(3,:))
x nxn matrix matlab code
x nxn matrix matlab code

About Matrix indexing in Matlab :

Also, in databases, indexing refers to extracting a single data point from a large data set.

The general purpose of an index is to quickly and easily extract values of interest from a database.

MATLAB also allows users to store and retrieve data from databases.

Vector and matrix indexing matlab :

>> A = magic(5)

A =

    17    24     1     8    15
    23     5     7    14    16
     4     6    13    20    22
    10    12    19    21     3
    11    18    25     2     9

>> A(1,:)

ans =

    17    24     1     8    15

>> A(:,1)

ans =

    17
    23
     4
    10
    11

>> A(3,5) % Extract the element in row 3, column 5

ans =

    22

>> A(1:3,2:4)  % Extract the vectors

ans =

    24     1     8
     5     7    14
     6    13    20

>> A(:,1)
Matrix indexing in Matlab
Matrix indexing Matlab

Conclusion – xnxn matrix matlab plot algorithm

In conclusion of this article we had an overview of how to create and make a plot or plot3 of an nxnxn matric in matlab. Also we have seen how the indexing of a matlabe matrix or a vector works. I offer more advanced functions in a following article.

External links – xnxn matrix matlab plot algorithm:

https://fr.mathworks.com/matlabcentral/fileexchange/62962-matrix-plotting

https://fr.mathworks.com/matlabcentral/answers/62349-how-to-plot-a-matrix

https://fr.mathworks.com/matlabcentral/answers/231806-how-can-plot-a-matix?s_tid=answers_rc1-1_p1_Topic

https://128mots.com/index.php/2022/03/13/modulo-matlab/

https://128mots.com/index.php/2021/09/06/meshgrid-matlab/

https://128mots.com/index.php/2021/06/26/x-nxn-matrix-matlab/

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *