How to import an audio file to simulink from app designer

16 ビュー (過去 30 日間)
Roberto Lemaitre
Roberto Lemaitre 2021 年 5 月 23 日
コメント済み: Roberto Lemaitre 2021 年 5 月 24 日
Right now i can select an audio file from my pc from App Designer but i need to know how to use it on simulink. Something like the "To multimedia file" block:
Here's the code i use for playing the song at the moment from App Designer:
So basically i need to be able to use the audio file i select from app designer inside simulink and work with it from there. Thanks!

採用された回答

jibrahim
jibrahim 2021 年 5 月 24 日
Hi Roberto,
Maybe this answers your scenario: In your App designer code, once the user has selected the file, you can use set_param to set the FIlename parameter of a 'From Multimedia File' block to the selected name. You can then run your model and have access to the desired audio signal in Simulink
  3 件のコメント
jibrahim
jibrahim 2021 年 5 月 24 日
編集済み: jibrahim 2021 年 5 月 24 日
Sure.
Let's say your model is called myModel.
Your model must be loaded or open (either works) before you can modify it. This code does it:
load_system('myModel') % The model will load, but does not open
open_system('myModel') % The model opens
You can execute this code outside your APP, or you can include this code in some initialization section, so that the model loads when you start using the APP.
Now let's say the 'From Multimedia File' block in your model is named myReader. To change the filename from which the block reads, execute:
set_param('myModel/myReader','Filename',myName)
where myName is a string/char vector containing the name of the file from which you want to read. In your APP code, insert that set_param code to react to a change in the filename.
Note that you cannot change the file name on the Simulink block while the model is running, so make sure the model is stopped before you execute this set_param.
To run the model programtically, use sim, e.g.
sim('myModel')
Roberto Lemaitre
Roberto Lemaitre 2021 年 5 月 24 日
Thanks a lot!! it worked!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBlock Libraries についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by