matlab - (Matlab) Transform a vector into matrix by keeping the numbers by pairs
问题描述
Let's say I have a vector that contains some coordinates (x,y) in this way:
A=[1 2 3 4 5 6 7 8 9 10]
And I want to transform it in this matrix:
A = [1 2
3 4
5 6
7 8
9 10]
How can I do it? 'reshape' command is not what I'm searching. Thanks for the help.
解决方案
Reshape 按列填充输出数组,因此您希望将其整形为 2x5 数组,然后转置:
>> A=[1 2 3 4 5 6 7 8 9 10];
>> reshape(A,2,[]).'
ans =
1 2
3 4
5 6
7 8
9 10
推荐阅读
- blazor - Blazor WebAssembly 第三方 API
- c# - 如何使用 URL 将二进制文件下载到 Android 设备?
- google-apps-script - Google 表格:运行脚本时排除选项卡
- delphi - 如何在 dll 中定义新对象?pax编译器
- java - 通过 EAP 7.2 和 OpenJDK11 的 java.security 文件配置 java 安全提供程序的问题
- npm - 无法在 Powershell Windows 上的新 Phoenix 项目中运行“npm install”
- vb.net - 为什么我的相机没有任何反应
- python - 如何运行 Dask pypy
- java - 如何在 Spring Boot 中使用 @Valid 验证对象?
- javascript - 使用父/子路由文件的奇怪行为