% this script will get a vector of timestamps from Matlab workspace via file % and create a new event variable with the vector values doc = GetActiveDocument() name = "x" Trace("NeuroExplorer is showing DIALOG. Make sure that NeuroExplorer window is visible") Dialog(doc, name, "Matlab variable name", "string") tempDir = "C:\ProgramData\Nex Technologies\NeuroExplorer\" tempFile = tempDir + "matlab_data" % clear previously saved data: write zero to the file script = "theFid=fopen('"+tempFile+"','w');fwrite(theFid,0,'int32');fclose(theFid);clear theFid;" ExecuteMatlabCommand(script) script = "if exist('"+name+"','var')==0,return,end;" script = script + "if min(size("+name+"))~=1,return,end;" script = script + "theSize=max(size("+name+"));" script = script + "theFid=fopen('"+tempFile+"','w');" script = script + "fwrite(theFid,theSize,'int32');" script = script + "fwrite(theFid,"+name+",'float64');" script = script + "fclose(theFid);clear theFid; clear theSize;" %Trace(script) ExecuteMatlabCommand(script) file = OpenFile(tempFile, "r") n = ReadBinary(file, "int") if n == 0 Trace("ERROR: zero vector size: variable", name, "does not exist in Matlab workspace or variable is not a single row or single column matrix") CloseFile(file) return end % we create the variable with the same name as the variable name in Matlab doc[name] = NewEvent(doc, 0) for i=1 to n ts = ReadBinary(file, "double") AddTimestamp(doc[name], ts) end CloseFile(file)