<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using MATLAB  to Grade</title>
	<atom:link href="http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Peter Perkins</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32787</link>
		<dc:creator>Peter Perkins</dc:creator>
		<pubDate>Thu, 01 Dec 2011 18:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32787</guid>
		<description>Bob, the Statistics Toolbox User Guide does have a section on dataset arrays if you haven&#039;t looked there:

http://www.mathworks.com/help/toolbox/stats/bqziht7-1.html#bqzihxq

To answer your specific question, you can add two variables in a dataset array by just adding them to create a new variable:

   d = dataset(randn(10,1),randn(10,1));
   d.Var3 = d.Var1 + d.Var2;

Hope this helps.</description>
		<content:encoded><![CDATA[<p>Bob, the Statistics Toolbox User Guide does have a section on dataset arrays if you haven&#8217;t looked there:</p>
<p><a href="http://www.mathworks.com/help/toolbox/stats/bqziht7-1.html#bqzihxq" rel="nofollow">http://www.mathworks.com/help/toolbox/stats/bqziht7-1.html#bqzihxq</a></p>
<p>To answer your specific question, you can add two variables in a dataset array by just adding them to create a new variable:</p>
<p>   d = dataset(randn(10,1),randn(10,1));<br />
   d.Var3 = d.Var1 + d.Var2;</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren Shure</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32786</link>
		<dc:creator>Loren Shure</dc:creator>
		<pubDate>Thu, 01 Dec 2011 18:23:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32786</guid>
		<description>Bob-

I am not aware of other documentation.  There are some other posts in this overall blog that use dataset arrays as well.  Perhaps those would be useful to you.

--Loren</description>
		<content:encoded><![CDATA[<p>Bob-</p>
<p>I am not aware of other documentation.  There are some other posts in this overall blog that use dataset arrays as well.  Perhaps those would be useful to you.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32785</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Thu, 01 Dec 2011 16:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32785</guid>
		<description>Where can I find good reference for using dataset arrays beyond the Matlab help?

Specifically, how can I add two variables in a dataset?</description>
		<content:encoded><![CDATA[<p>Where can I find good reference for using dataset arrays beyond the Matlab help?</p>
<p>Specifically, how can I add two variables in a dataset?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32356</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 05 Jul 2011 12:55:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32356</guid>
		<description>Patrick-

Since RT-DA is not a valid identifier name in MATLAB, so the name gets replaced with one that can be used in MATLAB.

--Loren</description>
		<content:encoded><![CDATA[<p>Patrick-</p>
<p>Since RT-DA is not a valid identifier name in MATLAB, so the name gets replaced with one that can be used in MATLAB.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick de Man</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32344</link>
		<dc:creator>Patrick de Man</dc:creator>
		<pubDate>Thu, 23 Jun 2011 12:14:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32344</guid>
		<description>What if I want to use as a variable name &#039;RT-DA&#039;?
The dataset heading becomes: RT0x2FDA, as the - seems to be an invalid character for the dataset.</description>
		<content:encoded><![CDATA[<p>What if I want to use as a variable name &#8216;RT-DA&#8217;?<br />
The dataset heading becomes: RT0x2FDA, as the &#8211; seems to be an invalid character for the dataset.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Perkins</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32129</link>
		<dc:creator>Peter Perkins</dc:creator>
		<pubDate>Fri, 18 Mar 2011 13:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32129</guid>
		<description>Roman, it looks like you&#039;ve got the hang of using nominal/ordinal variables in a dataset for creating subsets of your data.  The only problem I see in your code is this:

&lt;pre&gt;
~data.MLIndustryLvl2 == ‘Financial’
&lt;/pre&gt;

Consider the precedence of the operators &quot;~&quot; and &quot;==&quot;.  data.MLIndustryLvl2 is not a logical, so you want either

&lt;pre&gt;
~(data.MLIndustryLvl2 == ‘Financial’)
&lt;/pre&gt;

or

&lt;pre&gt;
data.MLIndustryLvl2 ~= ‘Financial’
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Roman, it looks like you&#8217;ve got the hang of using nominal/ordinal variables in a dataset for creating subsets of your data.  The only problem I see in your code is this:</p>
<pre>
~data.MLIndustryLvl2 == ‘Financial’
</pre>
<p>Consider the precedence of the operators &#8220;~&#8221; and &#8220;==&#8221;.  data.MLIndustryLvl2 is not a logical, so you want either</p>
<pre>
~(data.MLIndustryLvl2 == ‘Financial’)
</pre>
<p>or</p>
<pre>
data.MLIndustryLvl2 ~= ‘Financial’
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roman</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32128</link>
		<dc:creator>Roman</dc:creator>
		<pubDate>Fri, 18 Mar 2011 09:49:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32128</guid>
		<description>May I further ask:

% Extract all bonds with currency EUR and rating between BBB3 and A1 and not being Financials:
data( data.Rating &gt;= &#039;BBB3&#039; &amp; data.Rating &lt;=&#039;A1&#039; &amp; ~data.MLIndustryLvl2 == &#039;Financial&#039; ... 
     &amp; data.ISOCurrency ==&#039;EUR&#039;, {&#039;Description&#039;,&#039;Ticker&#039;,&#039;MLIndustryLvl3&#039;,&#039;YldToWorst&#039;,&#039;OAS&#039;, &#039;ModDurToWorst&#039;,&#039;Rating&#039;})
Matlab error message:
??? Undefined function or method &#039;not&#039; for input arguments of type &#039;nominal&#039;.

How can I efficiently code and then screen my database for all bonds but the &#039;financial&#039; ones (in MLIndustryLvl2 I have 7 different bond types, in ML IndustryLvl3 it&#039;s 31 and Lvl4 is 88)</description>
		<content:encoded><![CDATA[<p>May I further ask:</p>
<p>% Extract all bonds with currency EUR and rating between BBB3 and A1 and not being Financials:<br />
data( data.Rating &gt;= &#8216;BBB3&#8242; &amp; data.Rating &lt;=&#8217;A1&#8242; &amp; ~data.MLIndustryLvl2 == &#8216;Financial&#8217; &#8230;<br />
     &amp; data.ISOCurrency ==&#8217;EUR&#8217;, {&#8216;Description&#8217;,'Ticker&#8217;,'MLIndustryLvl3&#8242;,&#8217;YldToWorst&#8217;,'OAS&#8217;, &#8216;ModDurToWorst&#8217;,'Rating&#8217;})<br />
Matlab error message:<br />
??? Undefined function or method &#8216;not&#8217; for input arguments of type &#8216;nominal&#8217;.</p>
<p>How can I efficiently code and then screen my database for all bonds but the &#8216;financial&#8217; ones (in MLIndustryLvl2 I have 7 different bond types, in ML IndustryLvl3 it&#8217;s 31 and Lvl4 is 88)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roman</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32127</link>
		<dc:creator>Roman</dc:creator>
		<pubDate>Fri, 18 Mar 2011 08:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32127</guid>
		<description>Thanks, Peter

Yes, I do use and need dataset, because my data is 14514 rows and 36 columns with different types of bond variables:
- many currencies
- Price, Yield, Duration, ISIN number information of different bonds
- Ratings, Sectors, Names, Maturities
I try to replicate the webinar about dataset arrays. Goal is: extract out of large universe subsamples of bonds with predefined characteristics such as certain ratings, sectors, within certain time-to-maturity brackets. See following code:

data( data.Rating &gt;= &#039;AA3&#039;, {&#039;Ticker&#039;, &#039;YldToWorst&#039;, &#039;Rating&#039;})

data( data.Rating &gt;= &#039;BBB3&#039; &amp; data.Rating &lt;=&#039;A1&#039; &amp; data.MLIndustryLvl2 == &#039;Industrials&#039; ...
    &amp; data.MLIndustryLvl3 == &#039;Healthcare&#039; &amp; data.ISOCurrency ==&#039;USD&#039; &amp; data.MaturityDate &lt;= datenum(&#039;Dec-01-2014&#039;), ...
    {&#039;Ticker&#039;, &#039;YldToWorst&#039;, &#039;ModDurToWorst&#039;,&#039;Rating&#039;})

Kind regards Roman</description>
		<content:encoded><![CDATA[<p>Thanks, Peter</p>
<p>Yes, I do use and need dataset, because my data is 14514 rows and 36 columns with different types of bond variables:<br />
- many currencies<br />
- Price, Yield, Duration, ISIN number information of different bonds<br />
- Ratings, Sectors, Names, Maturities<br />
I try to replicate the webinar about dataset arrays. Goal is: extract out of large universe subsamples of bonds with predefined characteristics such as certain ratings, sectors, within certain time-to-maturity brackets. See following code:</p>
<p>data( data.Rating &gt;= &#8216;AA3&#8242;, {&#8216;Ticker&#8217;, &#8216;YldToWorst&#8217;, &#8216;Rating&#8217;})</p>
<p>data( data.Rating &gt;= &#8216;BBB3&#8242; &amp; data.Rating &lt;=&#8217;A1&#8242; &amp; data.MLIndustryLvl2 == &#8216;Industrials&#8217; &#8230;<br />
    &amp; data.MLIndustryLvl3 == &#8216;Healthcare&#8217; &amp; data.ISOCurrency ==&#8217;USD&#8217; &amp; data.MaturityDate &lt;= datenum(&#8216;Dec-01-2014&#8242;), &#8230;<br />
    {&#8216;Ticker&#8217;, &#8216;YldToWorst&#8217;, &#8216;ModDurToWorst&#8217;,'Rating&#8217;})</p>
<p>Kind regards Roman</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Perkins</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32126</link>
		<dc:creator>Peter Perkins</dc:creator>
		<pubDate>Fri, 18 Mar 2011 01:32:53 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32126</guid>
		<description>Roman, I&#039;m not exactly sure what&#039;s what in your code snippets, so I&#039;ll have to take a guess.  data looks like it might be a dataset array, with MaturityDate as one of its variables, and MaturityDate looks like it might be a cell array of datestrs where some are like &#039;01.02.2003&#039; and some are like &#039;02-Mar-2004&#039;.  It appears that you&#039;ve applied arrayfun to that cell array to get all &quot;/&quot;&#039;s, and reassign in place.

But I&#039;m not sure what you&#039;re up to with datasetfun.  It is intended to apply the same function to several variables in a dataset array, and since you only seem to be working on one variable, there&#039;d be no point in using it.

If all you want to do is to convert MaturityDate from datestr to datenum, you could use the same arrayfun strategy.  But the following is a vectorized version:

&lt;pre&gt;
MaturityDate = {&#039;01.02.2003&#039;; &#039;02-Mar-2004&#039;; &#039;03.04.2005&#039;; &#039;04-May-2006&#039;; &#039;05.06.2007&#039;};
data = dataset(MaturityDate)

MaturityDateDN = zeros(length(data.MaturityDate),1);
fmt10 = cellfun(@(x)length(x)==10,data.MaturityDate);
MaturityDateDN(fmt10) = datenum(data.MaturityDate(fmt10),&#039;dd.mm.yyyy&#039;);
fmt11 = ~fmt10;
MaturityDateDN(fmt11) = datenum(data.MaturityDate(fmt11),&#039;dd-mmm-yyyy&#039;);

data.MaturityDate = MaturityDateDN
&lt;/pre&gt;

When I run this, data starts out as

data = 
    MaturityDate     
    &#039;01.02.2003&#039;     
    &#039;02-Mar-2004&#039;    
    &#039;03.04.2005&#039;     
    &#039;04-May-2006&#039;    
    &#039;05.06.2007&#039;     

and ends up as

data = 
    MaturityDate
    7.3161e+05  
    7.3201e+05  
     7.324e+05  
     7.328e+05  
     7.332e+05</description>
		<content:encoded><![CDATA[<p>Roman, I&#8217;m not exactly sure what&#8217;s what in your code snippets, so I&#8217;ll have to take a guess.  data looks like it might be a dataset array, with MaturityDate as one of its variables, and MaturityDate looks like it might be a cell array of datestrs where some are like &#8217;01.02.2003&#8242; and some are like &#8217;02-Mar-2004&#8242;.  It appears that you&#8217;ve applied arrayfun to that cell array to get all &#8220;/&#8221;&#8216;s, and reassign in place.</p>
<p>But I&#8217;m not sure what you&#8217;re up to with datasetfun.  It is intended to apply the same function to several variables in a dataset array, and since you only seem to be working on one variable, there&#8217;d be no point in using it.</p>
<p>If all you want to do is to convert MaturityDate from datestr to datenum, you could use the same arrayfun strategy.  But the following is a vectorized version:</p>
<pre>
MaturityDate = {'01.02.2003'; '02-Mar-2004'; '03.04.2005'; '04-May-2006'; '05.06.2007'};
data = dataset(MaturityDate)

MaturityDateDN = zeros(length(data.MaturityDate),1);
fmt10 = cellfun(@(x)length(x)==10,data.MaturityDate);
MaturityDateDN(fmt10) = datenum(data.MaturityDate(fmt10),'dd.mm.yyyy');
fmt11 = ~fmt10;
MaturityDateDN(fmt11) = datenum(data.MaturityDate(fmt11),'dd-mmm-yyyy');

data.MaturityDate = MaturityDateDN
</pre>
<p>When I run this, data starts out as</p>
<p>data =<br />
    MaturityDate<br />
    &#8217;01.02.2003&#8242;<br />
    &#8217;02-Mar-2004&#8242;<br />
    &#8217;03.04.2005&#8242;<br />
    &#8217;04-May-2006&#8242;<br />
    &#8217;05.06.2007&#8242;     </p>
<p>and ends up as</p>
<p>data =<br />
    MaturityDate<br />
    7.3161e+05<br />
    7.3201e+05<br />
     7.324e+05<br />
     7.328e+05<br />
     7.332e+05</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roman</title>
		<link>http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32125</link>
		<dc:creator>Roman</dc:creator>
		<pubDate>Thu, 17 Mar 2011 12:26:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/#comment-32125</guid>
		<description>I use dataset with a large mixed matrix of values and strings
I have one variable with 14&#039;500 maturity dates of bonds. Unfortunately the maturity dates come in 2 varieties:
1.) dd.mm.yyyy
2.) dd-mmm-yyyy
changing to more appropriate date formats works fine:
data.MaturityDate=arrayfun(@(x)strrep(x,&#039;.&#039;,&#039;/&#039;),data.MaturityDate);
data.MaturityDate=arrayfun(@(x)strrep(x,&#039;-&#039;,&#039;/&#039;),data.MaturityDate);
However, trying to be efficient with dates by using datenum does not work. I tried many variants, even the following loop does not work:
for i=1,size(data,1);
    if length(data.MaturityDate{i})==10;
        data.MaturityDate{i}=datenum(data.MaturityDate{i},&#039;dd/mm/yyyy&#039;);
    elseif length(data.MaturityDate{i})==11;
        data.MaturityDate{i}=datenum(data.MaturityDate{i},&#039;dd/mmm/yyyy&#039;);
    else
        t=&#039;X&#039;
    end
end

Reading the blog I tried to use datasetfun

However I cannot figure out how to define (if possible) a datasetfun like:

f=@(x) length(x)==10, x=datenum(x,&#039;dd/mm/yyyy&#039;),... 
       length(x)==11, x=datenum(x,&#039;dd/mmm/yyyy&#039;) 

data.MaturityDate=datasetfun(f,dataMaturityDate);

Is there an efficient solution?

Regards Roman</description>
		<content:encoded><![CDATA[<p>I use dataset with a large mixed matrix of values and strings<br />
I have one variable with 14&#8217;500 maturity dates of bonds. Unfortunately the maturity dates come in 2 varieties:<br />
1.) dd.mm.yyyy<br />
2.) dd-mmm-yyyy<br />
changing to more appropriate date formats works fine:<br />
data.MaturityDate=arrayfun(@(x)strrep(x,&#8217;.',&#8217;/'),data.MaturityDate);<br />
data.MaturityDate=arrayfun(@(x)strrep(x,&#8217;-',&#8217;/'),data.MaturityDate);<br />
However, trying to be efficient with dates by using datenum does not work. I tried many variants, even the following loop does not work:<br />
for i=1,size(data,1);<br />
    if length(data.MaturityDate{i})==10;<br />
        data.MaturityDate{i}=datenum(data.MaturityDate{i},&#8217;dd/mm/yyyy&#8217;);<br />
    elseif length(data.MaturityDate{i})==11;<br />
        data.MaturityDate{i}=datenum(data.MaturityDate{i},&#8217;dd/mmm/yyyy&#8217;);<br />
    else<br />
        t=&#8217;X&#8217;<br />
    end<br />
end</p>
<p>Reading the blog I tried to use datasetfun</p>
<p>However I cannot figure out how to define (if possible) a datasetfun like:</p>
<p>f=@(x) length(x)==10, x=datenum(x,&#8217;dd/mm/yyyy&#8217;),&#8230;<br />
       length(x)==11, x=datenum(x,&#8217;dd/mmm/yyyy&#8217;) </p>
<p>data.MaturityDate=datasetfun(f,dataMaturityDate);</p>
<p>Is there an efficient solution?</p>
<p>Regards Roman</p>
]]></content:encoded>
	</item>
</channel>
</rss>

