2012-08-25 110 views
1

我对matlab非常陌生,需要一些帮助才能找到正确的语法来完成简单的数据图形任务。我有一个脚本可以分析一个波形并保存一个叫做特征的六点向量(它的值是< 3791x6 double>)。我需要通过第五个数据空间中的值,记录它们是否超过某个阈值,然后绘制结果图(时间对比上/下阈值)。Matlab基本数据图形

这里是基本的伪代码。什么是正确的Matlab语法?

create a time vs. boolean vector 'threshold' 
fifth column of 'features' equals new vector 'data' 
for each value in 'data' 
    if (data[index] > threshold value) threshold[index] = true 
    else threshold[index] = false 
graph(threshold) 

回答

1

的循环,如果条件相反,尝试:

data=features(:,5);

plot(data(data>threshold));

+0

OP不想仅绘制高于阈值的那些值 - 他们想要绘制两者的图形,但是要标识哪些高于或低于哪个值。另外它需要随时间绘制。 – Ansari

+0

对不起,你是正确的我的意思是情节(数据>阈值)。正如你也写道,这将产生一个长度(数据)的矢量,其中1为真,0为假。 – bla

+0

比我想象的要优雅得多 – Cbas

1

尝试是这样的:

vtime = 1:length(features(:, 5)); 
plot(vtime, features(:, 5) > threshold, '.'); 

变化vtime是你的时间向量如果这是不同的。