Azzera filtri
Azzera filtri

How do we write double matrix as an expression?

3 visualizzazioni (ultimi 30 giorni)
NN il 8 Feb 2023
Risposto: Jasvin il 9 Feb 2023
In matlab how do we write 1441x2 double matrix as an expression to specify any particular element , say 2x2
it is saved as Cost in the workspace.
  1 Commento
Les Beckham
Les Beckham il 8 Feb 2023
Are you asking how to pick out a certain section of the matrix to operate on?
Please explain what you mean by "write as an expression".
You should read this documentation page: Array Indexing
Also, I would recommend taking the time to go through the online tutorial here: Matlab Onramp

Accedi per commentare.

Risposte (1)

Jasvin il 9 Feb 2023
Assuming that you want to extract a 2x2 sub-matrix from a 1441x2 double matrix called "cost", here is how you would do that considering you want the 1st and 2nd columns from the 15th and 16th rows of the cost matrix,
cost(15:16, :)
This indexing means that you want all the rows from 15th to 16th and all the columns in the matrix which in this case would be the 1st and 2nd columns.
If you want two disjoint rows to be selected then you can do that too,
cost([16 1], :)
Note that this would fetch the rows in the same order that you specify in the indexing, so in this case the 16th row would be followed by the 1st row.


Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by