MATLAB Answers

0

Tgspcread function error (line 323)

Asked by Katherine on 12 Feb 2019
Latest activity Commented on by Arthur Goldsipe on 15 Feb 2019
I am attempting to use the tgspcread function in the Bioinformatics Toolbox to read a .spc file containing multiple spectra, but am receiving the following message. It had been working previous to updates to MATLAB, does anyone know how to solve it? Unfortunately my coding knowledge is pretty basic!
>> tgspcread('new.spc')
Reading header for file: new.spc
File contains 12826 scans
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Error in tgspcread (line 323)
outputHeader.FileSize = dirInfo.bytes;

  0 Comments

Sign in to comment.

1 Answer

Answer by Arthur Goldsipe on 12 Feb 2019

I think this is a bug in how the function tries to find out the size of the SPC file. You will see this error if the file is located in a folder that was added to MATLAB's path. The function fopen that opens the file is able to locate files on the MATLAB path, but the function dir that gives file information does not find files on the MATLAB path.
One solution is to change your current working directory to the folder that contains the SPC file before running the command. Another solution would be to specify the relative or absolute path to the file when you call tgspcread. For example, if you're using Linux, and the file is in the /tmp folder, you could update your line of code to tgspcread('/tmp/new.spc').

  8 Comments

I think the probem is that you're mixing forward slashes, /, and backslashes, \. I'm guessing you're using a Mac and need to change to consistently using forward slashes. Note that the first time you call tgspcread, it works because you're always using forward slashes. But the second time it fails because you're mixing in backslashes.
Thank you! This has been driving me mad all day. :)
Hi Ewan,
This is getting outside the scope of the original question, and it's a bit hard to follow along via comments. (It also makes it harder for other people with similar problems to find the solutions.) I recommend you make a new post in MATLAB Answers. If possible, I suggest attaching any relevant files so that other people can try to reproduce the problem.
-Arthur

Sign in to comment.