我正在使用简单的矩阵并得到一些奇怪的东西.
A =
2 3
5 6
8 9
Run Code Online (Sandbox Code Playgroud)
而我这样做了.
A([1 3],[1 2 2])
ans =
2 3 3
8 9 9
Run Code Online (Sandbox Code Playgroud)
而我这样做了.
A([1 3],[1 2])
ans =
2 3
8 9
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么MatLab有这个结果.
或者,更一般地说,A(输入)在最常见的输入中做了什么?
A(input)从传递的索引生成矩阵input.简单的例子就是
A(1,1) # select the element from first row, first column
A(2,:) # select the complete second row
A(:,2) # select the complete second column
A([1 2],1) # select the element from the first and second row and first column each
Run Code Online (Sandbox Code Playgroud)
从你的例子
A([1 3],[1 2 2]) # Select elements from first row and first and two times second column
#as well as third row with first and two times second column.
Run Code Online (Sandbox Code Playgroud)
类似
A([1 3],[1 2]) # Select elements from first row and first and second column
# as well as third row and first and second column
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29 次 |
| 最近记录: |