信号的八度频谱图“频谱图"如何工作? [英] How does Octave spectrogram 'specgram' from signal work?

查看:169
本文介绍了信号的八度频谱图“频谱图"如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试位于Octave信号包中的specgram函数,但是我对specgram的输入/输出变量有些困惑.我想做的是能够将频谱数据放入一个数组,该数组将显示频率以及频率开始和停止的时间长度.

I'm trying to test the specgram function located in the signal package in Octave but I'm a little confused at the input/output variables for specgram. What I would like to do is be able to get the specgram data into an array that will show the frequency and the length of time when the frequency starts and stops.

请参见下面的示例代码:我试图获取该数组,以显示对于t1的长度为7hz,t2为12hz,对于t3为2hz.我该怎么做呢?

See example code below: I was trying to get the array to show that for the length of t1 it will be 7hz, t2 will be 12hz and for t3 will be 2hz. How can I go about doing this?

我正在使用ubuntu 12.04和octave 3.2.4,以及信号包1.0.11

I'm using ubuntu 12.04 and octave 3.2.4 and the signal package 1.0.11

% combines sig with spectra plot
clear all,clc,tic;
fs=1000;
t1=linspace(0,2*pi,fs/0.1); %need to round off no decimals
t2=linspace(0,2*pi,fs/0.3); %need to round off no decimals
t3=linspace(0,2*pi,fs/0.6); %need to round off no decimals

%Create signal in different arrays
y1=sin(7*t1);
y2=sin(12*t2);
y3=sin(2*t3);

%append arrays to test specgram
yt = [y1 y2 y3];

%plot(yt) %will show combined plot

%Spectrum section
yts=specgram(yt',20,500, 2,1);
plot(yts)
fprintf('\nfinally Done-elapsed time -%4.4fsec- or -%4.4fmins- or -%4.4fhours-\n',toc,toc/60,toc/3600);

推荐答案

下面是一些执行此操作的示例代码.让别人告诉您升级软件并阅读说明会更好.

Here's some example code that will do this. Much better then having someone tell you to upgrade software, and read the instructions.

fs = 100;
t = 0:1/fs:10;
x = [sin(2*pi*7*t), sin(2*pi*12*t), sin(2*pi*2*t)];
specgram(x,256,1000, [],200);

这篇关于信号的八度频谱图“频谱图"如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆