C# application trying to reshape data in Matlab. In Matlab I need the data to appear 3-dimensional in the matlab instance. (The code assumes an instance of matlab is running.)
public void PassAndResizeInMatlab()
{
MLApp.MLApp matlab = (MLApp.MLApp)Marshal.GetActiveObject("Matlab.Desktop.Application");
matlab.Execute("enableservice('AutomationServer',true);");
var dat = new double[]{1,2,3,4};
var name = "myexample";
//matlab does not support passing double[,,] with this function.
matlab.PutWorkspaceData(name, "base", dat);
object varargout;
//this fails
matlab.Feval("reshape", 1, out varargout, name, new double[]{2,2});
//works but does not put the value in the matlab instance.
matlab.Feval("ones", 1, out varargout, 3,4,5); //works
//works but does not put the value in the matlab instance.
var output = matlab.Execute("reshape (" + name + ",2,2)");
}
Is it possible to modify existing data in matlab at all with COM?