Generate new model from SimMechanics Import XML file
H = smimport('filename')
H = smimport('filename', ModelName, 'modelname')
H = smimport('filename') imports SimMechanics™ XML file filename.xml into a new Simulink™ model with the same name. SimMechanics generates the new model according to XML file specification, adding and connecting any required blocks. For CAD-generated XML files, the new model represents a CAD assembly.
filename is a string specifying the XML file name. This string must be a valid model name, using any combination of letters, digits, and underscores such that the first character is a letter and the length of the string is smaller than namelengthmax. If filename is invalid, SimMechanics generates a valid name based on filename.
If a model with the same name is open,smimport returns a warning and appends an integer to filename in order to create a unique model name. If a model with the same name exists in the MATLAB workspace or path, smimport returns a warning asking you to change the model name.
filename supports path specification relative to the MATLAB working directory. Alternatively, filename can contain the full path to the corresponding XML file. In the absence of a path, smimport searches for filename inside the MATLAB path.
By default, smimport assumes filename refers to an XML file in the MATLAB workspace or path. filename does not require an explicit XML extension. If filename is not an XML file, or if it is not in the MATLAB workspace or path, smimport returns an error.
H = smimport('filename', ModelName, 'modelname') imports XML file filename into a new SimMechanics model with name modelname.
String specifying input XML file name. Replace filename with the XML file name you want to import. The .xml extension is optional.
This input is required.
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
String specifying generated SimMechanics model name.
This input is optional.
Generate robot model from SimMechanics Import XML file sm_robot.xml. The XML file represents a robot arm CAD assembly. You can access the XML file in the following directory:
The directory contains an additional set of STL files that specify 3-D surface geometry for all CAD parts.
At the command line, enter
In the new model window, select File > Save.
Enter model name and select storage directory
You can rename the robot model at the MATLAB command line. To rename the model robot_arm, add the model name to the smimport parameters.
At the MATLAB command line, enter
smimport('sm_robot', 'ModelName', 'robot_arm');
SimMechanics software imports file robot.xml and generates a new model called walkingrobot.