MATLAB Answers

Tgspcread function error (line 323)

7 views (last 30 days)
Katherine on 12 Feb 2019
Commented: 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;


Sign in to comment.

Answers (1)

Arthur Goldsipe
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').


Show 5 older comments
Arthur Goldsipe
Arthur Goldsipe on 14 Feb 2019
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.
Ewan Hislop
Ewan Hislop on 14 Feb 2019
Thank you! This has been driving me mad all day. :)
Arthur Goldsipe
Arthur Goldsipe on 15 Feb 2019
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.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!