如何在MATLAB中从给定的输入数据生成以下矩阵和向量? [英] How do I generate the following matrix and vector from the given input data in MATLAB?
本文介绍了如何在MATLAB中从给定的输入数据生成以下矩阵和向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有输入data = [1 2 3 4 5 6 7 8 9 10]
和num = 4
.我想使用这些来生成以下内容:
Suppose I have the inputs data = [1 2 3 4 5 6 7 8 9 10]
and num = 4
. I want to use these to generate the following:
i = [1 2 3 4 5 6; 2 3 4 5 6 7; 3 4 5 6 7 8; 4 5 6 7 8 9]
o = [5 6 7 8 9 10]
基于以下逻辑:
length of data = 10
num = 4
10 - 4 = 6
i = [first 6; second 6;... num times]
o = [last 6]
在MATLAB中自动化的最佳方法是什么?
What is the best way to automate this in MATLAB?
推荐答案
这里是使用功能 查看全文