<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The ILNumerics Blog &#187; Matlab</title>
	<atom:link href="https://ilnumerics.net/blog/category/matlab/feed/" rel="self" type="application/rss+xml" />
	<link>https://ilnumerics.net/blog</link>
	<description>The Productivity Machine  &#124;  A fresh attempt for scientific computing  &#124;  http://ilnumerics.net</description>
	<lastBuildDate>Thu, 05 Dec 2024 09:09:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Why MINT-students should learn C# instead of Matlab and R</title>
		<link>https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/</link>
		<comments>https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/#comments</comments>
		<pubDate>Sat, 30 May 2020 10:20:48 +0000</pubDate>
		<dc:creator><![CDATA[Jonas]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[Numerical Algorithms]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Scientific Computing]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=1017</guid>
		<description><![CDATA[<p>For students who want to prototype and code, there’s a wide range of domain specific programming languages around: R or Matlab – just to name a few – make it quite easy to design new algorithms, analyze data and to plot complex functions. However, bringing innovation from science to enterprise-ready software applications still costs lots &#8230; <a href="https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/" class="more-link">Continue reading <span class="screen-reader-text">Why MINT-students should learn C# instead of Matlab and R</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/">Why MINT-students should learn C# instead of Matlab and R</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>For students who want to prototype and code, there’s a wide range of domain specific programming languages around: R or Matlab – just to name a few – make it quite easy to design new algorithms, analyze data and to plot complex functions. However, bringing innovation from science to enterprise-ready software applications still costs lots of effort, manpower and experience.</p>
<p>Microsoft’s C# has the potential to fully close this gap: in combination with the ILNumerics numerical library, it becomes the perfect environment both for prototyping and creating powerful software. But why is it that the mainstream in science still doesn’t make use of the power of C#, .NET and Visual studio? Well, let’s have a closer look at computing in academia.</p>
<h2>Scientific Computing vs. Real-Life Applications</h2>
<p>Like in many other areas in academia, the main reason for sticking to out-of-date techniques is “tradition”. That’s why in 2020 there is still a huge gap between mathematical prototyping and industrial-grade production software. Scientists often aim at creating an algorithm solely in order to validate a new model or theory. Once done, they produce a couple of nice looking plots, publish a paper or two and: bye bye.</p>
<p>Unless&#8230; there is a greater use to it!</p>
<h2>Turning Prototypes into Products</h2>
<p>If a model created in science has the potential to earn serious money,  the algorithm created by a mathematician, physicist or microbiologist has to be transformed into something &#8216;production ready&#8217; that can be used in real life.</p>
<p>This is where many development teams in the biggest enterprises are stuck today: Everytime they want to adapt innovation from science for their own software applications, they have to translate Matlab, numpy or R codes into a modern, managed SW framework. This transformation is where the pain starts: It has to be done! And not only once, but with each update. This causes a whole lot of redundant and boilerplate code &#8211; each and every time. This work is expensive: It requires expert knowledge, extensive testing and additional maintenance. And it significantly delays the time to market!</p>
<h2>C# + ILNumerics: Perfect Match for High Performance Applications</h2>
<p>This pain needs to stop. And this is where modern general purpose languages come into play. C# for example fulfills all the requirements for the design of numerical algorithms! Developer tools such as Visual Studio &#8211; especially if complemented with the ILNumerics Array Visualizer und its highly efficient n-dimensional arrays &#8211; allow scientists and software developers to design and prototype their algorithms by directly using production-ready tools.</p>
<p>That means: the painful and time consuming transformation from domain specific prototyping code to an industrial software product is no longer necessary, which allows for huge time savings – often more than 50 percent!</p>
<h2>Maths, Physics, Engineering: Boost Innovation now!</h2>
<p>However, most established scientists in academia today still stick to Matlab, numpy and R &#8211; even though it’s not necessary anymore. But fortunately, a new generation of scientists has started to push innovation at universities ahead. They are often familiar with modern programming languages like C#, and they want to use their knowledge to combine academic prototyping with state of the art software development. This new generation will modernize the intersections between science and industry. Their skills will allow companies all over the world to realize all their innovative potential in a much shorter period of time.</p>
<p>That’s why we think any science and engineering student should get familiar with modern programming languages as early as possible: It will help him or her to boost innovation in their field all over the world!</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/">Why MINT-students should learn C# instead of Matlab and R</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/why-mint-students-should-learn-c-instead-of-matlab-and-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HDF5 and Matlab Files &#8211; Fun with ILNumerics</title>
		<link>https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/</link>
		<comments>https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/#comments</comments>
		<pubDate>Thu, 19 Mar 2015 08:12:25 +0000</pubDate>
		<dc:creator><![CDATA[Balázs]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ILNumerics]]></category>
		<category><![CDATA[Matlab]]></category>
		<category><![CDATA[array visualizer]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[h5dataset]]></category>
		<category><![CDATA[h5file]]></category>
		<category><![CDATA[HDF5]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[mat]]></category>

		<guid isPermaLink="false">http://ilnumerics.net/blog/?p=790</guid>
		<description><![CDATA[<p>Why to use HDF5 and ILNumerics? HDF5 is a file format (Hierarchical Data Format) especially desgined to handle huge amount of numerical data. Just to mention an example,  NASA chose it to be the standard file format for storing data from the Earth Observing System (EOS). ILNumerics easily handles HDF5 files. They can be used &#8230; <a href="https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/" class="more-link">Continue reading <span class="screen-reader-text">HDF5 and Matlab Files &#8211; Fun with ILNumerics</span> <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/">HDF5 and Matlab Files &#8211; Fun with ILNumerics</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h3>Why to use HDF5 and ILNumerics?</h3>
<p style="text-align: justify;">HDF5 is a file format (Hierarchical Data Format) especially desgined to handle huge amount of numerical data. Just to mention an example,  NASA chose it to be the standard file format for storing data from the Earth Observing System (EOS).</p>
<p style="text-align: justify;">ILNumerics easily handles HDF5 files. They can be used to exchange data with other software tools, for example Matlab mat files. In this post I will show a step by step guide &#8211; how to interface ILNumerics with Matlab.</p>
<p style="text-align: justify;"><span id="more-790"></span></p>
<h3>Save Matlab data to HDF5 format</h3>
<p style="text-align: justify;">Let&#8217;s start by creating some arbitrary data with Matlab and saving it in HDF5 format, Matlab supports it from 2006 September, version 7.3.</p>
<pre class="brush: matlabkey; title: ; notranslate">
matrix = randn(10, 10) * 5;
vector = [1 2 3 4 5]';
carr = 'It is a char array!';
noise = rand(1,100) - rand(1, 100);
sinus = 10 * sin(linspace(0, 2*pi, 100)) + noise;
complex = rand(1, 5) * (10 + 10i);
save('test_hdf5.mat', '-v7.3');
</pre>
<h3>Load Matlab data with ILNumerics</h3>
<p>Let&#8217;s now see what ILNumerics sees <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<figure id="attachment_791" style="width: 408px;" class="wp-caption alignnone"><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/1.png"><img class="wp-image-791 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/1.png" alt="ILNumerics HDF5 File peek view" width="408" height="228" /></a><figcaption class="wp-caption-text">Children datasets of H5File</figcaption></figure>
<p style="text-align: justify;">Matlab simply stored all arrays as individual datasets in the root node of the HDF5 file. It is now easily possible to access the data! We could take a peek and inspect them right within the Visual Studio debugger visualizers. But let’s see how the data is loaded programmatically:</p>
<pre class="brush: csharp; title: ; notranslate">
// Reading from Matlab
using (H5File file = new H5File(&quot;test_hdf5.mat&quot;))
{
    using (ILScope.Enter())
    {
        ILArray&lt;double&gt; matrix = file.Get&lt;H5Dataset&gt;(&quot;matrix&quot;).Get&lt;double&gt;();
        ILArray&lt;double&gt; vector = file.Get&lt;H5Dataset&gt;(&quot;vector&quot;).Get&lt;double&gt;();
        ILArray&lt;char&gt; carr = file.Get&lt;H5Dataset&gt;(&quot;carr&quot;).Get&lt;char&gt;();
        ILArray&lt;double&gt; noise = file.Get&lt;H5Dataset&gt;(&quot;noise&quot;).Get&lt;double&gt;();
        ILArray&lt;double&gt; sinus = file.Get&lt;H5Dataset&gt;(&quot;sinus&quot;).Get&lt;double&gt;();
    }
}

</pre>
<p style="text-align: justify;">The datasets are loaded &#8211; and the whole process was very easy. It took me less than ten minutes to figure out the methods. It would have been even less if I had take a look on the <a href="http://ilnumerics.net/examples.php">examples</a> of ILNumerics <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<p style="text-align: justify;">Now, let&#8217;s startup the <a title="ILNumerics Array Visualizer" href="http://ilnumerics.net/Visual-Studio-Graphical-Debugger.html">Array Visualizer</a>! Just write &#8216;array&#8217; in the Quick Launch box of Visual Studio, or open a new visualizer window via VIEW -&gt; OTHER WINDOWS -&gt; Array Visualizer. In the visualizer expression field enter: &#8216;sinus&#8217;. The array is now visualized, how cool is that <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<h3><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/33.png"><img class="alignnone wp-image-825 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/33.png" alt="ILNumerics Array Visualizer - Drawing local array on the fly" width="664" height="662" /></a></h3>
<h3>Visualizing Matlab mat files &#8211; on the fly</h3>
<p style="text-align: justify;">Now we have shown the content of the variable &#8216;sinus&#8217;. Just as well, we could visualize the content of the HDF5 file and have the visualizer follow any changes to it immediately:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/5.png"><img class="alignnone wp-image-826 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/5.png" alt="ILNumerics Array Visualizer - Reading HDF5 file" width="639" height="425" /></a></p>
<p style="text-align: justify;">If we multiply it with -1, the expression is immediately evaluated:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/6.png"><img class="alignnone wp-image-827 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/6.png" alt="ILNumerics Array Visualizer - Expression evaluation on the fly" width="639" height="425" /></a></p>
<p style="text-align: justify;">And what is even more interesting, if we change the HDF5 file interactively, in the immediate window, the ILNumerics Array Visualizer reflects that on the fly:</p>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/7.png"><img class="alignnone wp-image-829 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/7.png" alt="Manipulating HDF5 file content in immediate window" width="607" height="131" /></a> <a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/8.png"><img class="alignnone wp-image-828 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/8.png" alt="ILNumerics Array Visualizer - Reading HDF5 content on the fly" width="639" height="425" /></a></p>
<h3>Loading ILArrays into Matlab</h3>
<p style="text-align: justify;">Now let us check, what happens if we want to go from ILNumerics to Matlab. Saving a noise cosine with the following code:</p>
<pre class="brush: csharp; title: ; notranslate">
// Writing some data to HDF5
// Note: It will not make it a proper mat file, only HDF5!
if (File.Exists(&quot;test_iln.mat&quot;))
    File.Delete(&quot;test_iln.mat&quot;);

using (H5File newFile = new H5File(&quot;test_iln.mat&quot;))
{
    using (ILScope.Enter())
    {
        ILArray&lt;double&gt; noisyCos = ILMath.cos(ILMath.linspace(0, 3 * Math.PI, 1000)) * 10 + ILMath.rand(1, 1000);
        H5Dataset set = new H5Dataset(&quot;noisyCos&quot;, noisyCos);
        newFile.Add(set);
    }
}
</pre>
<p style="text-align: justify;">Since the ILNumerics HDF5 is not a mat file format, the only way to load it (as for now) is with one of the &#8216;h5*&#8217; methods of Matlab. To check the info and load, the following code is used:</p>
<pre class="brush: matlabkey; title: ; notranslate">
h5info('test_iln.mat', '/')
noisyCos = h5read('test_iln.mat', '/noisyCos');
</pre>
<p>In this way, it is possible to load ILArrays into Matlab <img src="https://ilnumerics.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
<h3>Altering Matlab mat files in ILNumerics</h3>
<p style="text-align: justify;">It is possible to alter loaded mat files with some limitations. What I found is that the length of the array can not be changed. Obviously, Matlab mat files are created as datasets without chunks, so the dataspace size cannot be changed after the file was created. However, one can alter the data (without changing the size) :</p>
<pre class="brush: csharp; title: ; notranslate">
// Altering data of mat file (v7.3 format)
using (H5File file = new H5File(&quot;test_hdf5.mat&quot;))
{
    using (ILScope.Enter())
    {
        ILArray&lt;double&gt; sinus = file.Get&lt;H5Dataset&gt;(&quot;sinus&quot;).Get&lt;double&gt;();
        sinus.a = sinus * -1;
        file.Get&lt;H5Dataset&gt;(&quot;sinus&quot;).Set(sinus, &quot;0;:&quot;);
    }
}
</pre>
<p>Let me draw your attention to the use of the Set function here. I first tried to use:</p>
<pre class="brush: csharp; title: ; notranslate">
file.Get&lt;H5Dataset&gt;(&quot;dsname&quot;).Set(A);
</pre>
<p><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/4.png"><img class="alignnone wp-image-810 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/4.png" alt="HDF5 file altering Matlab data" width="804" height="546" /></a></p>
<p style="text-align: justify;">But this would attempt to overwrite the whole dataset &#8211; something which could potentially change the size, hence would require a chunked dataset. Therefore, I figured that I have to be more specific and need to provide the target data range also:</p>
<pre class="brush: csharp; title: ; notranslate">
file.Get&lt;H5Dataset&gt;(&quot;sinus&quot;).Set(sinus, &quot;0;:&quot;)
</pre>
<h3>More Limitations</h3>
<p>Out of curiosity I checked the complex array, to see if it is okay.</p>
<figure id="attachment_792" style="width: 656px;" class="wp-caption alignnone"><a href="http://ilnumerics.net/blog/wp-content/uploads/2015/03/2.png"><img class="wp-image-792 size-full" src="http://ilnumerics.net/blog/wp-content/uploads/2015/03/2.png" alt="Loading complex from Matlab" width="656" height="208" /></a><figcaption class="wp-caption-text">Loading a complex vector from mat file</figcaption></figure>
<p style="text-align: justify;">Unfortunately it throws a H5Exception, this is something I will look into and work on. Fixing this problem will require support for compound datatypes in our HDF5 API.</p>
<h3>Try out the example</h3>
<p>To play with it, head to the examples and download the code:<br />
<a title="Reading and Writing Matlab data with ILNumerics" href="http://ilnumerics.net/examples.php?exid=80c65dd5478b9726d6313eed9ef7d241" target="_blank">Reading and Writing Matlab data with ILNumerics</a></p>
<h3>Conclusion</h3>
<p style="text-align: justify;">To sum up, it is possible and easy to load data stored in Matlab mat files to ILNumerics with the HDF5 IO handling, and it is also possible to load ILArrays to Matlab as well.</p>
<p style="text-align: justify;">I am opened to suggestions and feedback, looking forward to hearing from you! Share your experiences with us, so we can learn from you!</p>
<p>The post <a rel="nofollow" href="https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/">HDF5 and Matlab Files &#8211; Fun with ILNumerics</a> appeared first on <a rel="nofollow" href="https://ilnumerics.net/blog">The ILNumerics Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ilnumerics.net/blog/hdf5-and-matlab-files-fun-with-ilnumerics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
