Exporting Data
Use the export node to generate an animation or to export data to an external file (ASCII format). This section includes information about Animation Export, Data Export, and the Animation Player.
Animation Export
Animations can be defined as two different types: a movie or an image sequence. The movie generates file formats such as GIF (.gif), AVI (.avi), or flash (.swf); the image sequence generates a sequence of images. Make sure COMSOL with MATLAB using a graphics COMSOL Multiphysics Server to enable plot on server.
To generate an animation, add an Animation node to the export method:
anim = model.result.export.create(<animtag>, 'Animation')
To change the animation type use the 'type' property according to:
anim.set('type', type)
where anim is a link to an animation node and type is either 'imageseq' or 'movie'.
To set the filename and finally create the animation, enter:
anim.set(typefilename, <filenname>)
anim.run
In the above, typefilename depends on the type of animation export: 'imagefilename' for an image sequence, 'giffilename' for a gif animation, 'flashfilename' for a flash animation, and 'avifilename' for an avi animation.
For a movie type animation, it is possible to change the number of frames per second with the command:
anim.set('fps', <fps_number>)
where <fps_number> is a positive integer that corresponds to the number of frames per second to use.
For all animation types you can modify the width and the height of the plot with the set method:
anim.set('width', <width_px>)
anim.set('height', <height_px>)
where, the positive integers <width_px> and <height_px> are the width and height size (in pixels), respectively, to use for the animation.
Data Export
In order to save data to an ASCII file, create a Data node to the export method:
model.result.export.create(<datatag>, 'Data')
Set the expression expr and the file name filenname, and run the export:
model.result.export(<datatag>).setIndex('expr', <expr>, 0)
model.result.export(<datatag>).set('filename', <filenname>)
Set the export data format with the struct property:
model.result.export(<datatag>).set('struct', datastruct)
where datastruct can be set to 'spreadsheet' or 'sectionwise'.
See Data Formats in the COMSOL Multiphysics Programming Reference Manual for details about the data formats used in the exported data files.
To export the data in the specified file, run the export node:
model.result.export.(<datatag>).run
Animation Player
For transient and parametric studies, an animation player can be generated to create interactive animations.
The player displays the figure on a COMSOL Graphics window. Make sure COMSOL with MATLAB is started using a graphics COMSOL Multiphysics Server.
To create a player feature node to the model enter the command:
model.result.export.create(<playtag>, 'Player')
Then associate the player with an existing plot group by setting the plotgroup property:
model.result.export(<playtag>).set('plotgroup', <pgtag>)
where <pgtag> refers to the plot group, which is animated in the player.
The default frame number used to generate the animation is 25, you can also specify the number of frame with the command:
model.result.export(<playtag>).set('maxframe', <maxnum>)
where <maxnum> is a positive integer value that corresponds to the maximum number of frames to generate with the player.
Use the run method to generate the player:
model.result.export(<playtag>).run