import an old simulink model from 1995

6 visualizaciones (últimos 30 días)
Bart Verlaat
Bart Verlaat el 17 de Jun. de 2020
Editada: Fangjun Jiang el 17 de Jun. de 2020
Hello,
I want to load an old simulink model I made back in 1995. At this time simulink was still an .m file. I can load and see the text, but running it doesnot give me the wireframe model in the simulink window.
Does anybody know the tricks to get this old model working again in simulink?
Regards, Bart
  2 comentarios
Fangjun Jiang
Fangjun Jiang el 17 de Jun. de 2020
Are you sure the Simulink model (graphical diagram) file is a .m file? Could show a snip of the .m file?
Bart Verlaat
Bart Verlaat el 17 de Jun. de 2020
Editada: Rik el 17 de Jun. de 2020
Hi,
Here some start text to get an idea...
Bart
function [ret,x0,str]=dynaship(t,x,u,flag);
%DYNASHIP is the M-file description of the SIMULINK system named DYNASHIP.
% The block-diagram can be displayed by typing: DYNASHIP.
%
% SYS=DYNASHIP(T,X,U,FLAG) returns depending on FLAG certain
% system values given time point, T, current state vector, X,
% and input vector, U.
% FLAG is used to indicate the type of output to be returned in SYS.
%
% Setting FLAG=1 causes DYNASHIP to return state derivatives, FLAG=2
% discrete states, FLAG=3 system outputs and FLAG=4 next sample
% time. For more information and other options see SFUNC.
%
% Calling DYNASHIP with a FLAG of zero:
% [SIZES]=DYNASHIP([],[],[],0), returns a vector, SIZES, which
% contains the sizes of the state vector and other parameters.
% SIZES(1) number of states
% SIZES(2) number of discrete states
% SIZES(3) number of outputs
% SIZES(4) number of inputs.
% For the definition of other parameters in SIZES, see SFUNC.
% See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.
% Note: This M-file is only used for saving graphical information;
% after the model is loaded into memory an internal model
% representation is used.
% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(1.2)
if(0 == (nargin + nargout))
set_param(sys,'Location',[12,57,611,190])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
% Subsystem 'Extras'.
new_system([sys,'/','Extras'])
set_param([sys,'/','Extras'],'Location',[15,77,366,370])
add_block('built-in/Clock',[sys,'/','Extras/Clock'])
set_param([sys,'/','Extras/Clock'],...
'position',[30,80,50,100])
add_block('built-in/To Workspace',[sys,'/','Extras/kloksignaal'])
set_param([sys,'/','Extras/kloksignaal'],...
'mat-name','clock',...
'buffer','10000',...
'position',[90,82,140,98])
add_block('built-in/Note',[sys,'/','Extras/Extra tools:'])
set_param([sys,'/','Extras/Extra tools:'],...
'Font Size',14,...
'position',[80,20,81,21])
% Subsystem 'Extras/Diagrammen'.
new_system([sys,'/','Extras/Diagrammen'])
set_param([sys,'/','Extras/Diagrammen'],'Location',[691,229,926,414])
set_param([sys,'/','Extras/Diagrammen'],...
'Mask Display','Load',...
'Mask Type','',...
'Mask Dialogue','eval(''diamenu'')',...
'Mask Translate','',...
'Mask Help','')
% Finished composite block 'Extras/Diagrammen'.
set_param([sys,'/','Extras/Diagrammen'],...
'position',[235,65,270,99])
add_line([sys,'/','Extras'],[55,90;80,90])
% Finished composite block 'Extras'.
set_param([sys,'/','Extras'],...
'position',[435,20,465,70])
% Subsystem 'Telegrafen'.
new_system([sys,'/','Telegrafen'])
set_param([sys,'/','Telegrafen'],'Location',[14,77,366,371])
add_block('built-in/Gain',[sys,'/','Telegrafen/Telegraaf'])
set_param([sys,'/','Telegrafen/Telegraaf'],...
'hide name',0,...
'Gain','0',...
'Mask Display','0',...
'Mask Type','',...
'Mask Dialogue','eval(''telegraf([],[],-135,0,200,0)'');',...
'Mask Translate','',...
'Mask Help','')
set_param([sys,'/','Telegrafen/Telegraaf'],...
'position',[95,59,135,91])
add_block('built-in/Step Fcn',[sys,'/',['Telegrafen/Interactieve',13,'telegraaf']])
set_param([sys,'/',['Telegrafen/Interactieve',13,'telegraaf']],...
'Time','7')
set_param([sys,'/',['Telegrafen/Interactieve',13,'telegraaf']],...
'Mask Display','plot(0,0,100,100,[83,80,76,67,49,33,25,20,19],[30,40,50,60,66,60,50,41,30],[50,50,78,83,54,50],[30,37,78,74,32,30],[83,87,86,82,78,78],[74,76,81,83,82,78])')
set_param([sys,'/',['Telegrafen/Interactieve',13,'telegraaf']],...
'position',[30,59,60,91])
add_block('built-in/Note',[sys,'/','Telegrafen/Telegrafen:'])
set_param([sys,'/','Telegrafen/Telegrafen:'],...
'Font Size',14,...
'position',[65,15,66,16])

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 17 de Jun. de 2020
Editada: Fangjun Jiang el 17 de Jun. de 2020
This .m file is still valid on its concept. It runs M-script or commands to create a Simulink model on-the-fly. If you run "dynaship" you can see a blank Simulink is opened. But some of the Simulink model properties have been changed so this dynaship.m could NOT successfully create the Simulink model.
The first line of probelm is
set_param(sys,'algorithm', 'RK-45')
you need to change it to
set_param(sys,'solver','ode45')
And then many other lines.
The point is, Simulink was never a .m file. Simulink was a .mdl file and now it could be a .mdl or a .slx file.
Your .m file contains commands such as new_system(), set_param(), add_block(), add_line() to create the Simulink model. These commands are still valid but the model properties have been changed.

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by