LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Within a MATLAB Script Node Causing Access Violation

In my VI, I attempt to save data inside MATLAB structs in a .mat file for the ease of users that do their data analysis in MATLAB and do not want to take time importing and converting data. The code in my MATLAB script is simple:

 


 

zPosition = theData(1,: ); %these default to smileys on the forums... what is the escape character?
divSignal = theData(2,: );
xPosition = theData(3,: );
yPosition = theData(4,: );
metadata = struct('springConstant',springConstant,'powerPeak',powerPeak,'slope',slope,'timeSinceLastRecording',timeSinceLastRecording,'numSamples',numSamples,'zScanSize',zScanSize,'zRampRate',zRampRate,'scanDirection',scanDirection);
eval(['experimentalRun', num2str(runNumber), '=struct(''zPosition'',zPosition,''divSignal'',divSignal,''xPosition'',xPosition,''yPosition'',yPosition,''metadata'',metadata)']);
nameStr = strcat ('experimentalRun',num2str(runNumber));
if exist(fileLocation,'file')==0
    save(fileLocation,nameStr)
else
    save(fileLocation,nameStr,'-append')
end


I have attached the VI (used as a subVI in my application). When I run this, I get an Access Violation when the MATLAB script runs. I have attemped to run MATLAB with the same values that occur in LabVIEW and the .m file runs fine.

 

0 Kudos
Message 1 of 2
(2,491 Views)

Alternatively, is there a way to save LabVIEW data in binaries of a similar format - a structure with a sector of data and a number of metadata items? This could be preferrable to saving as MATLAB files, as long as the files that LabVIEW outputted could be easily read into MATLAB and re-created in similar structures.

0 Kudos
Message 2 of 2
(2,476 Views)