Psuedo-code (faster with git bash installed):
- fopen() toucshtone for read, fseek() to end of file (eof).
- fseek() backwards and appropriate amount (as determined by number of ports) to before last frequency point.
- Read line-by-line, and use regexp test to find valid frequency as first entry.
- Record start of chop point (before valid frequency entry) using ftell()
- Run git bash split (matlab dos execution), cleanup unneccesary files, & rename corrected file
- or use fprintf() to rewrite a new touchstone file (can be time intensive for large files)
Usage:
ClipLastFreq(filename,0) or ClipLastFreq(filename) %for git bash split
ClipLastFreq(filename,1) %for matlab fprintf()