当前位置:网站首页>Matlab matrix index problem
Matlab matrix index problem
2022-04-23 20:37:00 【Zhongai0049】
matlab Matrix index problem
Always meet matlab Matrix index problem , You have to check the information every time to remember , Just sum up today , There are several cases :
1. Matrix index to extract sub matrix
Pattern | meaning |
---|---|
M(i,j) | The first i Xing di j The elements of the column |
M(i,:) | The first i Row element |
M(:,j) | The first j Row column element |
M(a:a+m,b:b+n) | The first a~a+m That's ok ,b~b+n Elements in columns |
M(a:a+m,:) | The first a That's ok ~a+m Elements of the line |
A(c1:c2:c3) | The element whose sequence number satisfies the colon expression |
2. Find the index of matrix elements that meet the conditions
use find() Function to find the index of non-zero elements , The grammar is as follows :
k = find(X)
k = find(X,n)
k = find(X,n,direction)
[row,col] = find(___)
[row,col,v] = find(___)
k = find(X) Returns an array containing X Vector of linear index of each non-zero element in .
If X Vector , be find The return direction is the same as X The same vector .
If X For multidimensional arrays , be find Returns the column vector consisting of the linear index of the result .
If X Contains non-zero elements or is empty , be find Returns an empty array .
k = find(X,n) Return and X The non-zero element in the corresponding front n An index .
k = find(X,n,direction)( among direction by ‘last’) Find and X The last of the nonzero elements in n An index .direction The default value is ‘first’, That is, find the first... Corresponding to non-zero elements n An index .
[row,col] = find(___) Use any of the input parameters in the previous syntax to return an array X Row and column subscripts for each non-zero element in .
[row,col,v] = find(___) Also returns contains X Vector of non-zero elements of v.
3. The index matrix can be used to determine the elements in the matrix
Example : For one 1080*1920 In terms of the picture matrix , Give each pixel a color . The specific index is shown in the figure above . among k0 Index matrix ( Its size is the same as that of the image matrix ), The elements stored inside are color matrix tmp( The values stored inside can be understood as different colors ) The sequence number of the element in the . therefore , For pixels (1,1) Come on , Its color is tmp(k0)=x3.
Then there are other situations , And then add !
If there is a problem , Welcome to correct !!
版权声明
本文为[Zhongai0049]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210547163106.html
边栏推荐
- I JS deep copy and shallow copy
- [latex] 5 how to quickly write out the latex formula corresponding to the formula
- 【PTA】L1-006 连续因子
- Use of node template engine
- 【PTA】L2-011 玩转二叉树
- Leetcode 74. Search two-dimensional matrix
- Scrapy教程 - (2)寫一個簡單爬蟲
- Latest investigation and progress of building intelligence based on sati
- Common form verification
- Install MySQL 5.0 under Linux 64bit 6 - the root password cannot be modified
猜你喜欢
【栈和队列专题】—— 滑动窗口
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
Some basic configurations in interlij idea
High paid programmer & interview question series 91 limit 20000 loading is very slow. How to solve it? How to locate slow SQL?
go-zero框架数据库方面避坑指南
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
Vscode download speed up
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
How can matlab obtain the truncated image in trainingimagelabeler
随机推荐
The problem of 1 pixel border on the mobile terminal
Leetcode 709, convert to lowercase
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
Operation of numpy array
2021-06-29 C escape character cancellation and use
bounding box iou
Commit and rollback in DCL of 16 MySQL
Es error: request contains unrecognized parameter [ignore_throttled]
Why does ES6 need to introduce map when JS already has object type
CONDA environment management command
Unity Odin ProgressBar add value column
. Ren -- the intimate artifact in the field of vertical Recruitment!
"Meta function" of tidb 6.0: what is placement rules in SQL?
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
Leetcode 20. Valid parentheses
GO语言开发天天生鲜项目第三天 案例-新闻发布系统二
star
On BIM data redundancy theory
Common form verification