Find reason for this warning msg: Variable 'hws' originally saved as a handle cannot be instantiated as an object and will be read in as a uint32.

6 次查看(过去 30 天)
load_system('input_check')
hws = get_param('input_check', 'modelworkspace');
hws.DataSource = 'MAT-File';
hws.FileName = 'slx_input_check_pars.mat';
hws.reload; % Line 66
% sim('input_check')
close_system('input_check')
I am loading some parameters to model workspace of Simulink model 'input_check', code is shown above, run the code get a warning msg as,
Warning: Variable 'hws' originally saved as a handle cannot be instantiated as an object and will be read in as a uint32.
> In run_idp (line 66)
line 66 is marked in the code, % Line 66
I am worried about whether this property woud cause error later so want to know what causes this warning. Isn't 'reload' a valid function?
hws = get_param(bdroot, 'modelworkspace');
hws.DataSource = 'MAT-File';
hws.FileName = 'params';
hws.assignin('pitch', -10);
hws.assignin('roll', 30);
hws.assignin('yaw', -2);
hws.saveToSource;
hws.assignin('roll', 35);
hws.reload;
  2 个评论
Hainan Wang
Hainan Wang 2020-7-9
编辑:Hainan Wang 2020-7-9
load_system('input_check')
hws = get_param('input_check', 'modelworkspace');
hws.DataSource = 'MAT-File';
hws.FileName = 'slx_input_check_pars.mat';
hws % get(hws)
hws.reload; % Line 66 % reload variable from an external file to model workspace
% sim('input_check')
close_system('input_check')
Hi,
If I type get(hws) before warning appears, that pops out an error msg:Error using run_idp ()
Cannot get/set MATLABCode property for workspace unless data source is 'MATLAB
Code'.
Instead I type hws before warning appears(shown in code), here is the result shown in cmd window:
hws =
Simulink.ModelWorkspace
DataSource: 'MAT-File'
FileName: 'slx_input_check_pars.mat'
Warning: Variable 'hws' originally saved as a handle cannot be instantiated as an
object and will be read in as a uint32.
> In run_idp (line 66)

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2020-7-10
My suspect is that there is a variable also called 'hws' in the .mat file. It was the handle of an object. For example, the handle of certain graphical object appear to be the value of an integer. It was saved to the .mat file by accident.
The object no longer exists. Thus, when you reload the .mat file to the model workspace. The error message appears.
Check the content of your .mat file. Attach it here if possible. Also indicate your MATLAB version.
  2 个评论
Hainan Wang
Hainan Wang 2020-7-10
Hi,
My matlab version is 20a.
Your answer solved my question perfectly! I loaded slx_input_check_pars.mat file to base workspace and indeed as you said, there is 'hws' saved as a unit32.
Steven Lord
Steven Lord 2020-7-10
What does whos -file when run with the name of your MAT-file show should be the class of hws? Likely the definition of that class no longer exists or is no longer on your MATLAB path.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Manage Design Data 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by