MATLABfromCSharp.MatlabAccess.GetWorkspaceData C# (CSharp) Method

GetWorkspaceData() public static method

Grab data from the workspace.
public static GetWorkspaceData ( string name, string workspace, object &val ) : void
name string the name of the variable in the Matlab workspace.
workspace string the workspace name, (generally "base")
val object out the object from Matlab.
return void
        public static void GetWorkspaceData(string name, string workspace, out object val)
        {
            matlab.GetWorkspaceData(name, workspace, out val);
        }

Usage Example

Beispiel #1
0
        // Import to AF
        /// <summary>
        ///  Gets value from Matlab and writes it to AF.
        /// </summary>
        /// <remarks> Will not write, if the Attribute is read-only. A Matlab Variable Name must be input.</remarks>
        /// <param name="path"> The path to the Element to search with.</param>
        /// <param name="workspaceVariableName">The variable name in Matlab being used.</param>
        /// <param name="AFName">The attribute name in AF being written to.</param>
        public void ImportToAF(string path, string workspaceVariableName, string AFName)
        {
            object val = null;
            double dbVal;

            //LOGIC: A variable name must be entered.
            try
            {
                MatlabAccess.GetWorkspaceData(workspaceVariableName, "base", out val);
            }
            catch
            {
                mainForm.Status("Couldn't find the variable in the Matlab Workspace");
            }

            List <string> searchPaths = new List <string>()
            {
                path
            };
            AFKeyedResults <string, AFElement> results = AFElement.FindElementsByPath(searchPaths, null);
            AFElement   Element   = results[path];
            AFAttribute Attribute = Element.Attributes[AFName];

            double.TryParse(val.ToString(), out dbVal);
            try
            {
                AFAccess.writeToAF(Element, Attribute, dbVal);
            }
            catch
            {
                mainForm.Status("Cannot Write to this Attribute");
            }
        }