Azzera filtri
Azzera filtri

How to live plot Simulink data, and generate sound for specific ranges of y-values?

2 visualizzazioni (ultimi 30 giorni)
I currently have a Simulink model that gets data from sensors, which in turn is used to measure angles. I've brought the results from simulink back to the workspace, where I can be plot the data, see image. The data is displayed after measuring.
Is there any way that I can plot the data in real time and also play a sound when the y ouput is in a certain range. Lets say for example when the y-value is between [0,2], a sound is generated and between [2,4] a slighlty different sound is generated, etc.

Risposte (1)

Ayush Aniket
Ayush Aniket il 29 Set 2023
As per my understanding, you can achieve this by using real-time plotting in Simulink and using audio signals to generate sounds based on the range of your output.
For real-time plotting, you can use the "Scope" block in Simulink. This block can display your signal in real-time as your model is running. Just connect the output of your sensor data to the input of the Scope block.
For generating sounds, the first step would be to import your sound files into your workspace. You can use the `audioread` function to do this as shown below:
[sound, Fs] = audioread('sound.wav');
You can read more about the function on the following link:
Then you can use the "From Workspace" block to import a sound file into your Simulink model and the "Audio Device Writer" block to play the sound. You will need to use logic (like a "Switch" block or "If" block) to control when the sound is played based on the range of your output. The Audio Device Writer block writes audio samples to an audio output device and would be suitable for your task. You can refer to the following example for better understanding:
Hope it helps.

Categorie

Scopri di più su Audio I/O and Waveform Generation in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by