LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to use a working matlab script for opening special extension files with MathScript

Hello,

I have an issue with MathScript which doesn't run a working matlabscript.

I use a code on matlab which works for openning a particular file with a particular exetension. This code calls for different other files which are put in attachement.

Here is matlab code:



cd('C:\Users\Tual\Desktop\Ramanscript\loadwantedspectra\checkboxetest\MatlabSIFReader(2.99.10001.3)\atsifio');
rc=atsif_setfileaccessmode(0); %sets up the sif library to set the access property to load the entire file
absfilepath=strcat(PathName,FileName); % sets up the file name
rc=atsif_readfromfile(absfilepath); % attempt to open the file

if (rc == 22002) % check that the file was successfully opened
signal=0;
[rc,present]=atsif_isdatasourcepresent(signal); % check there is a signal present
if present
[rc,no_frames]=atsif_getnumberframes(signal); % query the number of frames contained in the file (e.g. in the instance of a kinetic series there may be more than 1
if (no_frames > 0)
[rc,size]=atsif_getframesize(signal);
[rc,left,bottom,right,top,hBin,vBin]=atsif_getsubimageinfo(signal,0); % get the dimensions of the frame to open
xaxis=0;
[rc,data]=atsif_getframe(signal,0,size); % retrieve the frame data
[rc,pattern]=atsif_getpropertyvalue(signal,'ReadPattern');
if(pattern == '0') %FVB
calibvals = zeros(1,size);
for i=1:size,[rc,calibvals(i)]=atsif_getpixelcalibration(signal,xaxis,(i)); %gets the x-calibration of each pixel (either pixel no. or wavelength
end
%plot(calibvals,data); % display the 1D data
%title('spectrum');
%set up the axis labelling appropriately
[rc,xtype]=atsif_getpropertyvalue(signal,'XAxisType');
[rc,xunit]=atsif_getpropertyvalue(signal,'XAxisUnit');
[rc,ytype]=atsif_getpropertyvalue(signal,'YAxisType');
[rc,yunit]=atsif_getpropertyvalue(signal,'YAxisUnit');
xlabel({xtype;xunit});
ylabel({ytype;yunit});
elseif(pattern == '4') % image
width = ((right - left)+1)/hBin;
height = ((top-bottom)+1)/vBin;
newdata=reshape(data,width,height); % reshape the 1D array to a 2D array for display
imagesc(newdata);
else
%TODO - implement for single-track, multi-track & random track
disp('It is not possible to display this acquisition format at this time...')
end
end
end
else
disp('Could not load file. ERROR - ');
disp(rc);
end


Hope someone can help me...

I am running labview 2014 (32bit)



Download All
0 Kudos
Message 1 of 4
(3,146 Views)

Hello,

 

I am Ed from National Instruments Technical Support. I'm happy to assist you with your issue regarding MathScript. I have some questions to provide me with greater context as to the case:

 

1. Is the code running on a cRIO, computer or PXI?

 

2. Are you receiving a specific error and if so what is said error?

 

I believe the issue may lie in that MathScript does not support all functions supported by the MATLAB software, some functions in your existing script might not be supported. This is explained in the help page linked below.

 

http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/labview_mathscript/


I believe the root cause of the issue will be that of the file io functions that are in use in the code you provided, instead of using such functions I would suggest the wavwrite and wavread since it seems that you are handling signal data. I have linked the two help pages below which describe these functions, I would recommend you make these implementation changes to your code and see if this provides the expected functionality you desire.

 

1. http://zone.ni.com/reference/en-XX/help/371361G-01/lvtextmath/msfunc_wavread/

 

2. http://zone.ni.com/reference/en-XX/help/371361G-01/lvtextmath/msfunc_wavwrite/

 

I hope that this is helpful and you are successful in your application.

 

Best regards,

 

Ed

0 Kudos
Message 2 of 4
(3,084 Views)

Hello Ed,

Thank you for your help.

I am running the labview on my computer.

I get this error message: "Unknown symbol on line 14 column 7: atsifiomex
C:\Users\Tual\Desktop\Ramanscript\loadwantedspectra\checkboxetest\MatlabSIFReader(2.99.10001.3)\atsifio\atsif_setfileaccessmode.m" which is a maxw64 extension, so maybe is a matter of bits MathScript version.

I will try these functions.

Regards,

Tual

0 Kudos
Message 3 of 4
(3,030 Views)

Hello,

 

I would recommend since it seems this is a file I/O function to use the functions I provided previously if indeed they do provide the functionality you require.

 

I would also recommend to use LabVIEW 32 bit even on 64 bit machines and maintain a 32 bit consistency throughout, this is because this has much greater support in way of modules and toolkits (functionality).

 

I hope that this is helpful and you are successful in your application.

 

Best regards,

 

Ed

0 Kudos
Message 4 of 4
(3,001 Views)