【问题标题】:Can someone tell me why this code is not running?有人能告诉我为什么这段代码没有运行吗?
【发布时间】:2019-05-04 10:48:28
【问题描述】:

我正在研究波束成形。同样,MathWorks 网站上有一个关于声学波束成形的示例代码。当我尝试运行代码时,它显示错误“未定义变量phased 或类phased.OmnidirectionalMicrophoneElement”。 谁能告诉我如何解决这个问题?

这里是代码

microphone = phased.OmnidirectionalMicrophoneElement('FrequencyRange',[20 20e3]);

Nele = 10; ula = phased.ULA(Nele,0.05,'Element',microphone); c = 340;  % sound speed, in m/s\

ang_dft = [-30; 0]; ang_cleanspeech = [-10; 10]; ang_laughter = [20; 0];

fs = 8000; collector = phased.WidebandCollector('Sensor',ula,'PropagationSpeed',c,...
    'SampleRate',fs,'NumSubbands',1000,'ModulatedInput', false);

t_duration = 3;  % 3 seconds t = 0:1/fs:t_duration-1/fs; prevS = rng(2008); noisePwr = 1e-4; % noise power % preallocate NSampPerFrame
= 1000; NTSample = t_duration*fs; sigArray = zeros(NTSample,Nele); voice_dft = zeros(NTSample,1); voice_cleanspeech = zeros(NTSample,1); voice_laugh = zeros(NTSample,1);

% set up audio device writer audioWriter = audioDeviceWriter('SampleRate',fs, ...
        'SupportVariableSizeInput', true); isAudioSupported = (length(getAudioDevices(audioWriter))>1);

dftFileReader = dsp.AudioFileReader('dft_voice_8kHz.wav',...
    'SamplesPerFrame',NSampPerFrame); speechFileReader = dsp.AudioFileReader('cleanspeech_voice_8kHz.wav',...
    'SamplesPerFrame',NSampPerFrame); laughterFileReader = dsp.AudioFileReader('laughter_8kHz.wav',...
    'SamplesPerFrame',NSampPerFrame);

% simulate for m = 1:NSampPerFrame:NTSample
    sig_idx = m:m+NSampPerFrame-1;
    x1 = dftFileReader();
    x2 = speechFileReader();
    x3 = 2*laughterFileReader();
    temp = collector([x1 x2 x3],...
        [ang_dft ang_cleanspeech ang_laughter]) + ...
        sqrt(noisePwr)*randn(NSampPerFrame,Nele);
    if isAudioSupported
        play(audioWriter,0.5*temp(:,3));
    end
    sigArray(sig_idx,:) = temp;
    voice_dft(sig_idx) = x1;
    voice_cleanspeech(sig_idx) = x2;
    voice_laugh(sig_idx) = x3; end

plot(t,sigArray(:,3)); xlabel('Time (sec)'); ylabel ('Amplitude (V)'); title('Signal Received at Channel 3'); ylim([-3 3]);

【问题讨论】:

  • 我正在删除 processing 标签,因为该问题与称为 Processing 的编程语言无关。在决定使用它之前,请阅读标签的描述。

标签: matlab signal-processing


【解决方案1】:

您必须从 Matlab 购买相控阵系统工具箱才能运行。

【讨论】:

    猜你喜欢
    • 2021-06-23
    • 2021-05-22
    • 1970-01-01
    • 2020-02-21
    • 2020-10-30
    • 2010-11-08
    • 2015-09-20
    • 1970-01-01
    相关资源
    最近更新 更多