visual3d:documentation:third-party:matlab:matlab
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
visual3d:documentation:third-party:matlab:matlab [2024/07/16 17:02] – removed sgranger | visual3d:documentation:third-party:matlab:matlab [2024/07/17 15:46] (current) – created sgranger | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Matlab ====== | ||
+ | |||
+ | Matlab is a challenging program to interact with because each version of Matlab seems to be incompatible with previous versions; not completely incompatible, | ||
+ | |||
+ | Visual3D communicates with Matlab in 4 different ways. | ||
+ | |||
+ | - By [[# | ||
+ | - Visual3D will [[# | ||
+ | - Release 12 and 13 of Matlab can be [[# | ||
+ | The Matlab dll's required for release 12 are the default files in Visual3D.\\ | ||
+ | To use Matlab release 13, the user should delete the release 12 dll's from the Visual3D installation folder, so that Visual3D links to the release 13 dll's on the computer.\\ | ||
+ | Matlab Release 14 compiler version 1 cannot be integrated, but Matlab Release 14 compiler version 2 can be, albeit with a different architecture in the compiled code.\\ | ||
+ | Matlab release 15 can also be integrated, but with another architecture in the compiled code.\\ | ||
+ | |||
+ | |||
+ | === Matlab dll's installed during Visual3D Installation === | ||
+ | |||
+ | Visual3D' | ||
+ | |||
+ | Remove the following dll's: | ||
+ | |||
+ | libeng.dll | ||
+ | libmat.dll | ||
+ | libmi.dll | ||
+ | libmx.dll | ||
+ | libut.dll | ||
+ | With the removal of these dll's Visual3D will search your **PATH** to find the installed Matlab dll's. | ||
+ | |||
+ | === Exporting signals to a Matlab .mat file === | ||
+ | |||
+ | A useful function of the Visual 3D scripting language is its ability to communicate with Matlab, a programming language specifically designed for technical computing. | ||
+ | |||
+ | Data can be exported from Visual 3D to a MAT file by using the **Export_Data_To_Matfile** command. This command allows you to save signal data and parameter data from Visual 3D into MAT format so it can be read by a Matlab function. You must specify the file name of the file from which the data is to be taken, the signal name, the signal type, whether or not the signal is processed or not, and the output name. The output name is simply the name of the variable that is saved in the MAT file; this is not necessarily the same as the signal name (see below). In addition to this, if you want to export parameters (data from the PARAMETERS branch of the data tree), you can include the **PARAMETER_GROUPS, | ||
+ | |||
+ | As an example, Visual3D will export data to Matlab (.mat) files using the following pipeline command syntax. This example was derived using the ExampleWalk.c3d file available on the website. | ||
+ | |||
+ | **Export_Data_To_Matfile** | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **! / | ||
+ | **! / | ||
+ | **! / | ||
+ | **;** | ||
+ | Note that Matlab 7.0 Release 14 is incompatible with Release 12 and 13; Visual3D currently import/ | ||
+ | |||
+ | == Matlab Cell Array == | ||
+ | |||
+ | Visual3D exports signals to a mat file as [[[https:// | ||
+ | |||
+ | For example, the following command: | ||
+ | |||
+ | **Export_Data_To_Matfile** | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **! / | ||
+ | **! / | ||
+ | **! / | ||
+ | **;** | ||
+ | places 4 cell arrays into the matfile. | ||
+ | |||
+ | RANK contains the contents of the signal RANKLE_ANGLE | ||
+ | FILE_NAME contains the names of the associated files in Visual3D | ||
+ | FRAME_RATE contains the Point Rate in Visual3D | ||
+ | ANALOG_VIDEO_FRAME_RATE contains the ratio analog rate to point rate | ||
+ | to extract the contents of the first file in the cell array for RANK, use the following Matlab syntax: | ||
+ | |||
+ | vec= RANK{1} | ||
+ | \\ | ||
+ | |||
+ | |||
+ | == Importing signals from a Matlab .mat file == | ||
+ | |||
+ | When exporting from Matlab, you need to use the option to save an old format (uncompressed) .mat file, as follows. | ||
+ | |||
+ | < | ||
+ | save(' | ||
+ | </ | ||
+ | |||
+ | Data can be imported to Visual3D using a syntax similar to export. | ||
+ | |||
+ | **Import_Data_From_Matfile** | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **;** | ||
+ | == Format of the mat file for Visual3D == | ||
+ | |||
+ | The format of the matfile is specific to Visual3D. The following example demonstrates a simple use of the mat file that reveals the particular syntax expected by Visual3D. | ||
+ | |||
+ | ! --------------------------------------------------------------------- | ||
+ | ! The example m-file is listed here. | ||
+ | ! To compile the m-file | ||
+ | ! Switch to dos (Command Prompt) | ||
+ | ! Change to directory containing the m-file | ||
+ | ! To create the executable | ||
+ | ! mcc -p average_3targets_return_target | ||
+ | ! | ||
+ | ! edit average_3targets_return_target.m | ||
+ | ! and add the following code | ||
+ | ! --------------------------------------------------------------------- | ||
+ | function testmfile | ||
+ | % load the file that was written out by C-Motion Visual3D | ||
+ | load c: | ||
+ | % loop throught the elements | ||
+ | for file=1: | ||
+ | [n1, | ||
+ | for frame=1:n1 | ||
+ | % Lets average the targets. | ||
+ | if ((SIGNAL1_IN{file}(frame, | ||
+ | (SIGNAL2_IN{file}(frame, | ||
+ | (SIGNAL3_IN{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | else | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | +SIGNAL3_IN{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | +SIGNAL3_IN{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | +SIGNAL3_IN{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | +SIGNAL3_IN{file}(frame, | ||
+ | SIGNAL_OUT{file}(frame, | ||
+ | +SIGNAL3_IN{file}(frame, | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | ===== Integrating Matlab Executables ===== | ||
+ | |||
+ | One of the most useful functions of the Visual 3D scripting language is its ability to communicate with Matlab, a programming language specifically designed for technical computing. Programs designed to perform data processing not handled by Visual 3D can be written in Matlab and called by a Visual 3D script. Data processed by Matlab programs can then be sent back to Visual 3D as new events or signals. | ||
+ | |||
+ | It is assumed that you know how to create m-files in the Matlab programming environment. If you do not know how to use Matlab, I recommend you take a look at the manual ’Getting Started with Matlab’; it provides a good overview of the Matlab environment and basic programming syntax. As well, you should have a recent version of Matlab (release 12 or higher) and the Matlab Compiler installed on your computer. | ||
+ | |||
+ | Communication between Visual 3D and compiled Matlab functions takes place by way of MAT files. MAT files are data files, readable only by Matlab and Visual 3D, that can contain any number of signal, event, or parameter data. | ||
+ | |||
+ | Data can be exported from Visual 3D to a MAT file by using the EXPORT_MATFILE command. This command allows you to save signal data and parameter data from Visual 3D into MAT format so it can be read by a Matlab function. You must specify the file name of the file from which the data is to be taken, the signal name, the signal type, whether or not the signal is processed or not, and the output name. The output name is simply the name of the variable that is saved in the MAT file; this is not necessarily the same as the signal name (see below). In addition to this, if you want to export parameters (data from the PARAMETERS branch of the data tree), you can include the PARAMETER_GROUPS, | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ! --------------------------------------------------------------- | ||
+ | ! CALL_MFILE | ||
+ | ! - save specified signals to a mat file | ||
+ | ! - run an exe compiled from Matlab that | ||
+ | ! reads a mat file | ||
+ | ! creates a new mat file | ||
+ | ! - load the new mat file into Visual3D | ||
+ | ! | ||
+ | !/ | ||
+ | ! specify the entire directory path | ||
+ | !/ | ||
+ | ! from Visual3D | ||
+ | !/ | ||
+ | !/ | ||
+ | !/ | ||
+ | ! | ||
+ | !/ | ||
+ | ! file. These are the names that | ||
+ | ! the .m file will see | ||
+ | ! | ||
+ | !/ | ||
+ | !/ | ||
+ | ! | ||
+ | !/ | ||
+ | ! when they are imported to Visual3D | ||
+ | !/ | ||
+ | ! | ||
+ | ! This example uses the ExampleTrial data that can be downloaded from the website. | ||
+ | ! --------------------------------------------------------------- --------------------- | ||
+ | **CALL_MFILE** | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | **/ | ||
+ | The CALL_MFILE command performs the following tasks: | ||
+ | |||
+ | - Exports data to a MAT file | ||
+ | - Runs a compiled Matlab-based .exe file to load the data, process the data, and create a new MAT file containing the processed data | ||
+ | - Imports the data from the second MAT file back into Visual 3D | ||
+ | |||
+ | * The OUTPUT_FILE parameter specifies the name of the MAT file to create | ||
+ | * OUTPUT_SIGNAL_NAMES, | ||
+ | * MFILE_NAME specifies the name of the compiled Matlab function to run (this must be an .exe file). | ||
+ | * INPUT_FILE specifies the MAT file from which the processed data is imported | ||
+ | * INPUT_NAMES are the variable names (in the m-file) that are read. | ||
+ | * The processed data is placed in the signals specified by INPUT_SIGNAL_NAMES and INPUT_SIGNAL_TYPES (this data is considered " | ||
+ | |||
+ | To clarify, the basic algorithm of the above CALL_MFILE command is illustrated below: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | Note that, in order to pass the time signal to a MAT file, you should use " | ||
+ | |||
+ | ===== Integrating Matlab dlls ===== | ||
+ | |||
+ | In a nutshell, to create a Matlab plugin you need to compile a Matlab script into a dll create a text file that describes to Visual3D what it's interface looks like and put both files in a directory named Matlab-Plugins in the Visual3D plugins directory. | ||
+ | |||
+ | **The text file must have a .txt extension and the same name as the .dll it describes. An example would be:** | ||
+ | |||
+ | $ ls MathLab-Plugins # (or ' | ||
+ | swindowlib.dll | ||
+ | swindowlib.txt | ||
+ | \\ | ||
+ | |||
+ | |||
+ | $ cat swindowlib.txt | ||
+ | swindow | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | **This tells Visual3D that swindowlib.dll has an entry point named swindo that takes 4 parameters: | ||
+ | |||
+ | - LSIGIN (an input signal) | ||
+ | - WINSIZE ( an input integer) | ||
+ | - WINSTEP (an input integer) | ||
+ | - SIGOUT (an output signal). | ||
+ | |||
+ | **Note: Signals are specified as TYPE: | ||
+ | |||
+ | **To Compile the dll** | ||
+ | |||
+ | function makedll(sName, | ||
+ | \\ | ||
+ | |||
+ | |||
+ | %MAKEDLL Compiles a Matlab function into a DLL. | ||
+ | % | ||
+ | % Usage: | ||
+ | % makedll(MFilename, | ||
+ | % | ||
+ | % Description: | ||
+ | % This function compiles a Matlab DLL from the M-file provided. Only a single file should | ||
+ | % be given, since dependencies are determined automatically. That is, any other M-file | ||
+ | % called will automatically be compiled and linked into the resulting DLL. Additional | ||
+ | % options to the MCC program can be provided, but none should be necessary in most cases. | ||
+ | % | ||
+ | % The resulting file will be called mfilenamelib.dll, | ||
+ | % directory. | ||
+ | % | ||
+ | % Parameters: | ||
+ | % MFilename The name of the M-file containing the entry-point function. | ||
+ | % [options] A variable number of strings which are appended to the standard compiler options. | ||
+ | % | ||
+ | % Remarks: | ||
+ | % There are some serious limitations on the kind of Matlab code which can be compiled | ||
+ | % into a stand-alone DLL. See the document " | ||
+ | % rules to follow. | ||
+ | % | ||
+ | % Copyright (C) 2004 C-Motion | ||
+ | % Author: Paul Cisek | ||
+ | % Created: 6/28/2004 mfilename | ||
+ | **Note: Remember to verify the path.** | ||
+ | |||
+ | % Path to Visual3D %%**%%* VERIFY THIS %%**%%* | ||
+ | vis3dpath = ' | ||
+ | %cd c: | ||
+ | % Build the command to the compiler | ||
+ | options = {}; | ||
+ | command = ['mcc -t -h -W lib:', | ||
+ | %command = [command,' | ||
+ | if nargin>1 | ||
+ | command = [command, | ||
+ | end | ||
+ | options = {'-O optimize_integer_for_loops: | ||
+ | if length(options)> | ||
+ | command = [command, | ||
+ | end | ||
+ | % Run the compiler | ||
+ | disp([' | ||
+ | eval(command); | ||
+ | % Copy the files | ||
+ | dos([' | ||
+ | dos([' | ||
+ | **Example files:** | ||
+ | |||
+ | test.m (Matlab file to be compiled into test.dll) | ||
+ | function out = stupid_test(in) | ||
+ | out = in; | ||
+ | **V3D pipeline command: test.v3d** | ||
+ | |||
+ | test | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | **test.txt (lets V3D know the interface to the dll)** | ||
+ | |||
+ | stupid_test | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | ===== Transferring Information between Visual3D and MATLAB ===== | ||
+ | |||
+ | **Please note for examples below:** When referring to segments in a pipeline script, it is better to use Visual3D’s internal three letter segment names (e.g., RTH instead of Right Thigh, etc.). For further details, see the segment_names.ini file installed in the Config folder along with Visual3D.exe under Program Files. | ||
+ | |||
+ | ==== Generating Visual3D Pipeline Scripts Using MATLAB ==== | ||
+ | |||
+ | Visual3D’s flexible pipeline scripting architecture can be further extended by automatically generating and pipeline scripts using MATLAB. Download this ([[https:// | ||
+ | |||
+ | The MatlabLaunchVisual3D zip file contains three Matlab functions (generatev3DPipeline, | ||
+ | |||
+ | < | ||
+ | generateV3DPipeline(' | ||
+ | </ | ||
+ | |||
+ | This function should produce the Visual3D pipeline **C: | ||
+ | |||
+ | Note: this function will probably need to be modified to reflect the user’s specific set of motion capture and model template files, etc. | ||
+ | |||
+ | A little background: generating a pipeline script using MATLAB is done in three steps: | ||
+ | |||
+ | - Open a file | ||
+ | - Write text strings that conform to Visual3D' | ||
+ | - Close the file | ||
+ | |||
+ | For example: | ||
+ | |||
+ | < | ||
+ | fid = fopen(’C: | ||
+ | fprintf(fid, | ||
+ | fprintf(fid, | ||
+ | fprintf(fid, | ||
+ | fclose(fid); | ||
+ | </ | ||
+ | |||
+ | When these commands are executed, a new file (**C: | ||
+ | |||
+ | ==== Running Visual3D Pipeline Scripts From MATLAB ==== | ||
+ | |||
+ | It is also possible, however, to have **Matlab launch Visual3D and execute this pipeline automatically.** | ||
+ | |||
+ | Visual3D can be run from the Windows command line prompt along with the /s switch followed by the name of a pipeline script to execute. | ||
+ | |||
+ | MATLAB provides the corresponding dos() function to run Windows applications. For example type the following at the Matlab command prompt: | ||
+ | |||
+ | < | ||
+ | dos(’Visual3D.exe /s C: | ||
+ | </ | ||
+ | |||
+ | Important: Visual3D.exe must be in the user’s path in order for the MATLAB dos() command to work properly. Alternatively, | ||
+ | |||
+ | < | ||
+ | dos(’" | ||
+ | </ | ||
+ | |||
+ | The Visual3D processing results dialog that results should reflect the above pipeline. | ||
+ | |||
+ | **Note to edit the path on Windows XP:** | ||
+ | |||
+ | - Click Start menu, then right click My Computer and select Properties. | ||
+ | - Click the Adanced tab and then the Environment Variables button. | ||
+ | - The path variable is in the System variables section. | ||
+ | |||
+ | See the **runV3DPipeline()** MATLAB function in the example files linked at the start of this topic for a working example of how to run this procedure from within an m-file. | ||
+ | |||
+ | At the Matlab prompt type: | ||
+ | |||
+ | < | ||
+ | runV3DPipeline(' | ||
+ | </ | ||
+ | |||
+ | Note that Visual3D remains active at the end of this function. If you want Visual3D to exit after running the pipeline, place the following command at the end of the pipeline. | ||
+ | |||
+ | < | ||
+ | Exit_Workspace | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | ==== Loading and Parsing MAT Files Generated With Visual3D ==== | ||
+ | |||
+ | MAT files are loaded using the load() MATLAB function. For example type the following at the Matlab command prompt: | ||
+ | |||
+ | **matData = load(’C: | ||
+ | |||
+ | The names of all the fields present in the file are found using the fieldnames() MATLAB function. For example: | ||
+ | |||
+ | **names = fieldnames(matData); | ||
+ | |||
+ | Finally, the actually data is obtained using the getfield() MATLAB function. For example: | ||
+ | |||
+ | **tmp = getfield(matData, | ||
+ | **if numel(tmp) > 0**\\ | ||
+ | **data = tmp{1};**\\ | ||
+ | **disp(data); | ||
+ | **end** | ||
+ | |||
+ | See the **loadMATData()** MATLAB function in the example files linked at the start of this topic for an example of how to load and parse the data fields in a MAT file. | ||
+ | |||
+ | At the Matlab command prompt enter: | ||
+ | |||
+ | **loadMATData(' | ||
+ | |||
+ | The example function provides a good starting point for parsing MAT files, however, problem specific details need to be considered by the end user. | ||
+ | |||
+ | ===== FIR and IRR Filter Design and Analysis ===== | ||
+ | |||
+ | Matlab' | ||
+ | |||
+ | < | ||
+ | filterDesigner | ||
+ | </ | ||
+ | |||
+ | Running filterDesigner will open an interface that can be used to design and analyze filters. The design techniques detailed in Matlab' | ||
+ | |||
+ | < | ||
+ | filterBuilder | ||
+ | </ | ||
+ | |||
+ | Running filterBuilder will start an interactive tool for building and testing filters. It both creates filter coefficients and can be used to filter test data. More information [[https:// | ||
+ | |||
+ | ===== Visual3D Pipeline Commands ===== | ||
+ | |||
+ | ==== Call_MFile ==== | ||
+ | |||
+ | Exports signals to an MFile routine, and imports results back to Visual3D. This should probably be simply called [[# | ||
+ | |||
+ | < | ||
+ | Call_MFile | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | ! / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | ==== Import_Data_From_Matfile ==== | ||
+ | |||
+ | Imports specified signals from a Matfile. | ||
+ | |||
+ | < | ||
+ | Import_Data_From_Matfile | ||
+ | / | ||
+ | !/ | ||
+ | / | ||
+ | /FILE_NAME= | ||
+ | / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | This function expects the .mat file to have a specific input. For example, within MATLAB, we write and run the following script: | ||
+ | |||
+ | < | ||
+ | array = linspace(0, | ||
+ | importThisData = {sin(array)}; | ||
+ | |||
+ | FRAME_RATE{1, | ||
+ | ANALOG_VIDEO_FRAME_RATIO{1, | ||
+ | FILE_PATH = {' | ||
+ | |||
+ | matDirectory = ' | ||
+ | save(matDirectory,' | ||
+ | </ | ||
+ | |||
+ | What is really important is the FILE_PATH. Within your Visual3D workspace, you will presumably have loaded some .c3d files (in this case, Sub01_Walk001.c3d). The address under FILE_PATH must match the location of the original .c3d files, even if that path is different from the path of the Visual3D workspace. If the Import_Data_From_Matfile command executes but doesn' | ||
+ | |||
+ | FILE_PATH is different from FILE_NAME, which should be the path to the .mat file you wish to import data from. | ||
+ | |||
+ | ==== Export_Data_To_Matfile ==== | ||
+ | |||
+ | This command is similar to [[# | ||
+ | |||
+ | {{: | ||
+ | |||
+ | It is very important to note that Visual3D expresses an unknown value (e.g. a TARGET with residual of -1) using the value DATA_NOT_FOUND (-99999). Matlab doesn' | ||
+ | |||
+ | < | ||
+ | Export_Data_To_Matfile | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! /FILE_NAME= | ||
+ | / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | ==== Get_From_Matlab ==== | ||
+ | |||
+ | Uses DCOM to put data from one active file in the Visual3D Workspace into Matlab (e.g. with Matlab running concurrently). | ||
+ | |||
+ | < | ||
+ | Get_From_Matlab | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | In Matlab the signal should appear with the Matlab_Item_Name. This is necessary because Matlab does not allow multiple signals with the same name but with a different type. | ||
+ | |||
+ | ==== Put_To_Matlab ==== | ||
+ | |||
+ | Uses DCOM to put data from one active file in the Visual3D Workspace into Matlab (e.g. with Matlab running concurrently). | ||
+ | |||
+ | < | ||
+ | Put_To_Matlab | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | In Matlab the signal will appear with the Matlab_Item_Name. This is necessary because Matlab does not allow multiple signals with the same name but with a different type. | ||
+ | |||
+ | ==== Export_Data_To_Matlab ==== | ||
+ | |||
+ | **THIS COMMAND DOES NOT WORK IN ANY VERSION OF MATLAB NEWER THAN Matlab R13. Use the Export_Data_to_Matfile command instead** | ||
+ | |||
+ | Visual3D will use DCOM to push signal directly in the Matlab Workspace without having to save the m-file. This command is different from Put_To_Matlab because it allows the data to be exported from all ACTIVE_FILES. This is possible because it uses a Matlab struct_array to store the data. | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | **Export_Data_To_Matlab** | ||
+ | |||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | For example, export 3 TARGETS (LFT1, LFT2, LFT3) from Visual3D to Matlab. | ||
+ | |||
+ | Invoke the Pipeline Edit Dialog | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | Add the name of the Matlab struct array and the first TARGET. Select the Add Data button | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | Add the remaining 2 signals | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | The text version of the pipeline command should look like this: | ||
+ | |||
+ | **Export_Data_To_Matlab** | ||
+ | |||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |**/ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | Execute the command with 4 active files in the Visual3D Workspace. | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | Matlab should contain the following struct_array | ||
+ | |||
+ | » TEST | ||
+ | |||
+ | TEST = | ||
+ | |||
+ | ANALOG_VIDEO_FRAME_RATIO: | ||
+ | FRAME_RATE: {4x1 cell} | ||
+ | FILE_NAME: {4x1 cell} | ||
+ | O_LFT1: {4x1 cell} | ||
+ | O_LFT2: {4x1 cell} | ||
+ | O_LFT3: {4x1 cell} | ||
+ | \\ | ||
+ | |||
+ | |||
+ | » TEST.O_LFT1 | ||
+ | |||
+ | ans = | ||
+ | |||
+ | [230x5 double] | ||
+ | [231x5 double] | ||
+ | [220x5 double] | ||
+ | [211x5 double] | ||
+ | ==== Import_Data_From_Matlab ==== | ||
+ | |||
+ | Visual3D will use DCOM to pull signals directly from the Matlab Workspace without having to save the m-file. This command is different from [[# | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | **Import_Data_From_Matlab** | ||
+ | |||
+ | |**/ | ||
+ | | | | | ||
+ | |**/ | ||
+ | | | | | ||
+ | |**/ | ||
+ | | | | | ||
+ | |**/ | ||
+ | | | | | ||
+ | |**/ | ||
+ | | | | | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== Eval_In_Matlab ==== | ||
+ | |||
+ | Causes a concurrent version of Matlab to execute the specified Matlab function. | ||
+ | |||
+ | **Eval_In_Matlab**\\ | ||
+ | / | ||
+ | **;** | ||
+ | |||
+ | ===== Examples ===== | ||
+ | |||
+ | === mFile for Tagging Files Based on Vicon Workstation Description === | ||
+ | |||
+ | This mFile was kindly provided by one of our customers. | ||
+ | |||
+ | Vicon Workstation provides a DESCRIPTION parameter for a file name. It may be convenient to use that DESCRIPTION to TAG the c3d file in Visual3D. | ||
+ | |||
+ | This [[https:// | ||
+ | |||
+ | The mFile exports a Visual3D pipeline command that can loaded and run in Visual3D. | ||
+ | |||
+ | === Read a text file exported from Visual3D into Matlab === | ||
+ | |||
+ | This sample code [[Visual3D: | ||
+ | |||
+ | |||
visual3d/documentation/third-party/matlab/matlab.1721149355.txt.gz · Last modified: 2024/07/16 17:02 by sgranger