<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Parse.m</id>
	<title>Parse.m - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-pnb.eri.ucsb.edu/index.php?action=history&amp;feed=atom&amp;title=Parse.m"/>
	<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Parse.m&amp;action=history"/>
	<updated>2026-04-20T17:38:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://wiki-pnb.eri.ucsb.edu/index.php?title=Parse.m&amp;diff=213&amp;oldid=prev</id>
		<title>128.111.101.185: Created page with '&lt;pre&gt; %PARSE2.M %Takes a string and returns val token. %Returns [] if val token does not exist. %Returns val token and rest of line if val&lt;0 including any blanks. %returns cell a…'</title>
		<link rel="alternate" type="text/html" href="https://wiki-pnb.eri.ucsb.edu/index.php?title=Parse.m&amp;diff=213&amp;oldid=prev"/>
		<updated>2010-08-05T23:51:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;pre&amp;gt; %PARSE2.M %Takes a string and returns val token. %Returns [] if val token does not exist. %Returns val token and rest of line if val&amp;lt;0 including any blanks. %returns cell a…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
%PARSE2.M&lt;br /&gt;
%Takes a string and returns val token.&lt;br /&gt;
%Returns [] if val token does not exist.&lt;br /&gt;
%Returns val token and rest of line if val&amp;lt;0 including any blanks.&lt;br /&gt;
%returns cell array of all tokens if val==0.&lt;br /&gt;
&lt;br /&gt;
%does the same thing as parse.m in a slightly different way.&lt;br /&gt;
&lt;br /&gt;
%useage: out=parse(string,val)&lt;br /&gt;
&lt;br /&gt;
function [out,rem]=parse(string,val);&lt;br /&gt;
&lt;br /&gt;
out=[];&lt;br /&gt;
cout={};&lt;br /&gt;
maxline=0;&lt;br /&gt;
for irow=1:size(string,1),&lt;br /&gt;
  p=[];&lt;br /&gt;
  r=string(irow,:);&lt;br /&gt;
  while ~isempty(r),&lt;br /&gt;
    [t,r]=strtok(r);&lt;br /&gt;
    p=strvcat(p,t);&lt;br /&gt;
  end&lt;br /&gt;
  prow{irow}=p;&lt;br /&gt;
  %pad lines with blanks to make all matrices on row same length&lt;br /&gt;
  maxline=max(maxline,size(p,1));&lt;br /&gt;
end&lt;br /&gt;
for irow=1:size(string,1),&lt;br /&gt;
  p=prow{irow};&lt;br /&gt;
  %pad lines with blanks to make all matrices on row same length&lt;br /&gt;
  nline=maxline-size(p,1);&lt;br /&gt;
  for iline=1:nline,&lt;br /&gt;
    p=strvcat(p,' ');&lt;br /&gt;
  end&lt;br /&gt;
  cout=[cout cellstr(p)];&lt;br /&gt;
end&lt;br /&gt;
cout=cout';&lt;br /&gt;
if abs(val)&amp;lt;=size(cout,2),&lt;br /&gt;
  if val&amp;lt;0,&lt;br /&gt;
    if length(val)~=1,&lt;br /&gt;
      error('parse.m: for val &amp;lt; 1, length(val) == 1.');&lt;br /&gt;
    end&lt;br /&gt;
    val=abs(val):size(cout,2);&lt;br /&gt;
  end&lt;br /&gt;
  if val~=0,&lt;br /&gt;
    for irow=1:size(cout,1),&lt;br /&gt;
      tout=[];&lt;br /&gt;
      for icol=val,&lt;br /&gt;
	tout=[tout cout{irow,icol} ' ' ];&lt;br /&gt;
      end&lt;br /&gt;
      out=strvcat(out,tout);&lt;br /&gt;
    end&lt;br /&gt;
    out=deblank(out);&lt;br /&gt;
  else,&lt;br /&gt;
    out=cout;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return&lt;br /&gt;
%TODO&lt;br /&gt;
%make work for string arrays with different numbers of words on&lt;br /&gt;
%each line.&lt;br /&gt;
&lt;br /&gt;
%if no val field put in an empty cell&lt;br /&gt;
&lt;br /&gt;
%add rem output of (val+1):end as a string&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;[[parse]]&amp;lt;big&amp;gt;&lt;/div&gt;</summary>
		<author><name>128.111.101.185</name></author>
		
	</entry>
</feed>