How do we write double matrix as an expression?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Les Beckham
le 8 Fév 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".
Also, I would recommend taking the time to go through the online tutorial here: Matlab Onramp
Réponses (1)
Jasvin
le 9 Fév 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!