How to add path to block From multimedia file, from Matlab workspace

8 ビュー (過去 30 日間)
Piotr
Piotr 2022 年 2 月 3 日
回答済み: Fangjun Jiang 2022 年 2 月 4 日
Hi,
I would like to add path to simulink simulation controlled by Matlab GUI. I wrote a code which get path to the file:
function browse_button_Callback(hObject, eventdata, handles)
[filename,filepath] = uigetfile({'*.mp3';'*.wav';'*.*'}, 'Search sound file to process');
fullname = [filepath filename];
But I cannot assign any variable to catch from workspace:
So I cannot write:
assignin("base","fullname",file);
In order to set this in parameters of .slx.
Is there any way code this path?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 2 月 4 日
To assign the value of "fullname" to a variable called 'file' in the base workspace, it needs to be:
assignin('base','file',fullname)
But still, this won't work as you expected.
You could do
fullname=fullfile(filepath,filename)
set_param(ThisFromMultimediumBlockPath, 'inputFilename',fullname)

カテゴリ

Help Center および File ExchangeNaming Conventions についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by