フィルターのクリア

Real time sound processing

13 ビュー (過去 30 日間)
quentin reynes
quentin reynes 2022 年 3 月 13 日
回答済み: Saurav 2024 年 2 月 22 日
Hello everyone,
I need to run an experiment of noise cancellation for my studies but I really struggle with real time implementation. I work with the model given by Matlab : https://fr.mathworks.com/help/audio/ug/active-noise-control-with-simulink.html;jsessionid=4d1d2039fa7ded5f648454c5ab90?s_eid=PSM_15028#d123e12440. However, when I try to replace the simulated sources by real ones, everything stops working because of a problem of type (I think). In particular, the LMS update block displays "Exepcted input to be a scalar". How can I fix this ? I'm pretty sure that if the program can process signals generated by the computer, there's a way to make it process signals measured by sensors.
I know that the question has already been asked a number of times here, but to my knowledge no one has ever got any answer. Just trying again! By the way if anyone wants to reply to this, I must say I'm a beginner.
If you guys could help me it would really mean a lot to me, thank you!
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 13 日
Is the model designed for mono but the microphone source is configured for stereo?

サインインしてコメントする。

回答 (1 件)

Saurav
Saurav 2024 年 2 月 22 日
Hello,
It is my understanding that you are trying to implement the “Active noise control with Simulink real-time” model example of Simulink by replacing the simulated sources with the real data coming out of sensors.
It throws an error because the LMS block expects a scalar input, but the data you are providing as an input might be a vector. Now, you need to ensure that even if your data is a vector, it should output one element of the vector at each simulation step.
Here is a workaround you can follow:
  1. Load your sensor data into the MATLAB’s workspace.
  2. Add a “MATLAB Function” block to your model (can be found in Simulink-> user-Defined functions).
  3. Double- click on the “MATLAB Function” block and write custom MATLAB code that outputs one element of the vector at each simulation step.
An example of what the MATLAB function code might look like:
function y = fcn(u)
% u is the input vector
persistent index;
if isempty(index)
index = 1;
end
y = u(index); % Output the current element
% Increment the index, and reset if it exceeds the length of u
index = index + 1;
if index > length(u)
index = 1;
end
end
4. Connect your vector data to the input of the “MATLAB Function” block. If your data is stored in a variable in your MATLAB’s workspace, say “sen_data”, you can use a constant block in Simulink and enter “sen_data” in the “Constant value” parameter of the block
5. Connect the output of the “MATLAB Function” block to the block that expects a scalar input-the LMS block in your case.
You can refer to the following documentation to learn more about the “MATLAB Function” block in Simulink:
I hope you find this helpful!

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by