NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/util/verbatim.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Add back slashes to get Latex *verbatim* form of character strings %
3 %% newstring=verbatim(oldstring)
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 function newstring=verbatim(oldstring)
6 size(oldstring);
7 nchar=ans(2);
8 %
9 % find locations and number of *_* entries
10 %
11 for i=1:nchar
12    if oldstring(1,i) == '_'
13       dash(i,1)=1;
14    else
15       dash(i,1)=0;
16    end
17 end
18 newstring=oldstring;
19 for i=nchar+1:nchar+sum(dash)
20    newstring(1,i)=' ';
21 end
22 index=0;
23 for i=1:nchar
24    index=index+1;
25    if dash(i) == 1
26       for ii=nchar+sum(dash):-1:index+1
27          newstring(1,ii)=newstring(1,ii-1);
28       end
29       newstring(1,index)='\';
30       index=index+1;
31    end
32 end
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the browser.