arrays - Matlab : expandable array, 丢失数据

标签 arrays matlab expandable

我有两列数据。第一列是时间,第二列是时间的函数。然而,一些时间值会丢失,因此函数值也会丢失。我不知道丢失行的索引(数据量太大)。例如,我有这个:

 t   x+w
2t  2x+w
3t  3x+w
6t  6x+w
7t  7x+w

但是,它应该是这样的:

 t   x+w
2t  2x+w
3t  3x+w
4t  4x
5t  5x
6t  6x+w
7t  7x+w

我想扩展时间数组并添加相应的函数值。实际上 f(t) 是随机的,但具有线性增长的确定性行为。因此,如果我在数千个值中添加两个值并不重要。那么我怎样才能在 Matlab 中做到这一点呢?

抱歉我的英语不好。我希望我能解释一下自己。 谢谢。

最佳答案

如果您的数据如下所示:

t = [1 2 3 6 7];
x = 2;
w = 10;
X = t*x + w;

现在你可以 interpolate获取缺失的 X 值:

ti = 1:7;
Xi = interp1(t, X, ti);

或者如果你说你有这个:

t = [1 2 3 6 7];
X = rand(size(t));

然后填写随机值:

Xi(t) = X; %Space out the origianl random value according to t
Xi(setdiff(1:7,t)) = rand() %Find the missing vlaues using setdiff and replace them with new random values
ti = 1:7;

关于arrays - Matlab : expandable array, 丢失数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16208751/

相关文章:

javascript - 如何根据内容获取数组序号?

javascript - 如何从一系列日期范围(可能有重叠的工作日期)中查找某人的工作经验年数

matlab - 如何将标签向量转换为 Octave 中的二进制向量?

arrays - 计算 MATLAB 中给定持续时间值的时间步长之间的均值

matlab - 对象方法中的自引用

arrays - 将组件推送到组件数组 - ReactJS

c - *** 检测到 glibc *** free() : invalid next size (fast) -- should work?

c# - ASP.NET 中的文本框自动扩展

android - 我如何在 android 中创建一个简单的可扩展列表

android - 如何在android中只展开textview