Odd behavior with a Simulink reserved name in a function?

6 ビュー (過去 30 日間)
Jim 2017 年 7 月 19 日
編集済み: Walter Roberson 2017 年 10 月 15 日
Not sure what to make of this. Running R2017a. I have a numeric double precision variable named f14n. I save it to a .mat file. I call a function that loads the mat file with variable f14n in it, and it becomes a Simulink model. This of course crashes the function because I'm treating f14n as a numeric variable. Threw together some ugly code (below) to reproduce what I'm describing. Variable f14n is fine in the calling script, but it launches a Simulink window in the function. Is this a bug or am I breaking a bunch of scripting rules here? Thanks.
save junk.mat f14n
function dum = junk_func(dum2)
load junk.mat


Steven Lord
Steven Lord 2017 年 7 月 19 日
Don't "poof" variables into the workspace like that. When MATLAB parsed junk_func it needed to know to what f14n referred. Since there was no indication in the code that it was a variable, and there is a Simulink® model available by that name, it treated that reference as opening that model.
  5 件のコメント


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by