Load data from *.mat file with mask

8 次查看(过去 30 天)
Timo
Timo 2023-3-27
评论: Timo 2023-3-28
Hello,
I have a Simulink model with a subsystem with a mask.
The mask accepts a string value as input.
The subsystem then calls the "From File" block to load data into the Simulink workspace. When I hardcode the path in the "From File" block, it works as expected, but when I want to use the mask value like "InputFile" and then assign the "InputFile" mask parameter a string value with the path to the file which shall be loaded, the "From File" block only looks for "InputFile.mat", and not the file in the path of the mask parameter. That is very weird, as it is correctly assigning the path value when I look into the "From File" block properties. It finds the path and resolves the mask parameter, but still tries to load from "InputFile.mat".
How can I solve this?
Thank you in advance!

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-3-27
For string parameters like folder and file name, you might not be able to pass it from the mask to the inside block parameter. Instead, I remember using a call-back of the masked string parameter. In the call-back, you use set_param() to set the file name of the "From File" block to be the value from the mask dialog.

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by