当前位置:网站首页>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
边栏推荐
- Leetcode 994, rotten orange
- 三十一. `prototype`显示原型属性和`__proto__`隐式原型属性
- 6-5 string - 2 String copy (assignment) (10 points) the C language standard function library includes the strcpy function for string copy (assignment). As an exercise, we write a function with the sam
- DNS cloud school rising posture! Three advanced uses of authoritative DNS
- Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
- The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
- Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
- On BIM data redundancy theory
- How to use PM2 management application? Come in and see
- Numpy mathematical function & logical function
猜你喜欢
随机推荐
Solution: NPM err! code ELIFECYCLE npm ERR! errno 1
Automatically fill in body temperature and win10 task plan
What is the difference between a host and a server?
[latex] 5 how to quickly write out the latex formula corresponding to the formula
缓存淘汰算法初步认识(LRU和LFU)
DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
Introduction to intrusion detection data set
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
Learn to C language fourth day
[graph theory brush question-4] force deduction 778 Swimming in a rising pool
【栈和队列专题】—— 滑动窗口
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
CONDA environment management command
Monte Carlo py solves the area problem! (save pupils Series)
Commit and rollback in DCL of 16 MySQL
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
How to do after winning the new debt? Is it safe to open an account online
BMP JPEG 图片转换为矢量图像 ContourTrace
Unity asset import settings
Leetcode 994, rotten orange