如何从矩阵中分离出一组连续的数字?
我有一个 3 列的矩阵。在第二列中,我有一个连续的数字,其增量为 2。假设该列中缺少一个数字,我想形成一个单独的连续数字组,并且我还必须采用相应的值到其他两列。
例如:
[1 2 3;
1 4 6;
1 6 0;
1 10 3;
1 12 6]...
在我的情况下,矩阵的阶数非常高,所以,您能告诉我哪个循环适用于这个问题以及如何解决这个问题吗?
I have a matrix with 3 columns. In the second column I have a continuous number which is having a increment of 2. Suppose in that column a number is missing in between, I want to form a separate group of number which is continuous, and also I have to take the values corresponding to the other two columns.
For example:
[1 2 3;
1 4 6;
1 6 0;
1 10 3;
1 12 6]...
In my case order of the matrix is very high so, can you please tell me which loop will work for this and how I can solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道我是否 100% 理解你的问题,但我会尝试一下。您可以使用
interp1
函数在丢失的数据点上插入数据。 Interp1 可以通过多种不同的方式进行插值,因此请查看它的帮助文件。对于您给出的矩阵和线性插值,我会执行以下操作:希望这有帮助!
I don't know if I understood your question 100% but I'll give this a shot. You can use the
interp1
function to interpolate data over your missing datapoint. Interp1 can do interpolation in a variety of different ways so take a look at its help file. In the case of the matrix you gave and with linear interpolation I would do the following:Hope this helps!