No BSD License  

Highlights from
scanfc

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 8.81 KB File ID: #12929

scanfc

by Peter Li

 

08 Nov 2006 (Updated 20 Nov 2006)

scanf rewritten to give cell arrray output

| Watch this File

File Information
Description

Major bug fixes in version 1.1 from 1.0. Upgrade strongly recommended.

This is a reimplementation of sscanf done to allow cell array output. Written as a mex file in C. I've decided it isn't practical for me to try to supply binaries, so you'll have to compile the source yourself using the MatLab "mex scanfc.c" command. If you have problems with compiling please let me know.

The native MatLab sscanf returns its output as a numeric or character array. This is a clumsy method that causes many problems, particularly with reading strings. My implementation with cell array output is more flexible and cleaner to use for complicated jobs.

I started with C code from the PHP project. I retooled the code for MatLab and also simplified and cleaned up as much as possible. I tried to mimic the behavior of native MatLab sscanf in terms of what formats are accepted and how it handles unusual format strings. Documentation is included in the scanfc.m file and also as comments in scanfc.c.

I have not yet had a chance to test this against a full suite of test cases, but the performance is to spec for my tests to date.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
09 Nov 2006

Some compiler problems, removing binary for now, will update ASAP.

20 Nov 2006

Major bug fixes. There was a problem with using "*" for scan suppression. There was a problem with integer format scans: spillover from previous scans due to failure to null terminate the scan buffer.

Tag Activity for this File
Tag Applied By Date/Time
data import Peter Li 22 Oct 2008 08:48:23
data export Peter Li 22 Oct 2008 08:48:23
mex Peter Li 19 Nov 2010 04:23:07
scanf Peter Li 19 Nov 2010 04:23:07
input Peter Li 19 Nov 2010 04:23:07
io Peter Li 19 Nov 2010 04:23:07

Contact us at files@mathworks.com