<?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>House-Tiere              -d(~_~)b- &#187; Scripts</title> <atom:link href="http://house-tiere.de/category/scripts/feed/" rel="self" type="application/rss+xml" /><link>http://house-tiere.de</link> <description>.. was auch immer das heißen mag.</description> <lastBuildDate>Sun, 05 Jun 2011 15:49:42 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.3</generator> <item><title>Flexible &amp; erweiterte Progressbar in Matlab mit Event-Listener</title><link>http://house-tiere.de/scripts/flexible-erweiterte-progressbar-in-matlab-mit-event-listener/</link> <comments>http://house-tiere.de/scripts/flexible-erweiterte-progressbar-in-matlab-mit-event-listener/#comments</comments> <pubDate>Sat, 12 Mar 2011 00:18:08 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Scripts]]></category> <category><![CDATA[Eventlistener]]></category> <category><![CDATA[Fortschritssanzeige]]></category> <category><![CDATA[matlab]]></category> <category><![CDATA[objekt orientiert]]></category> <category><![CDATA[Progressbar]]></category> <category><![CDATA[Waitbar]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=723</guid> <description><![CDATA[In Matlab fängt man mit Progressbars eigentlich recht simpel an. Und dann wirds größer und man will Informationen unterbringen, zum Beispiel wieviel Zeit vergangen ist, wieviel noch verbleibt, diverse Zwischenstände. Und wenn erst einmal für eine Funktion eine solche komplexe Waitbar erstellt hat, möchte man sie auch weiterverwenden, austauschen, konfigurieren, etc. Wie man das recht [...]]]></description> <content:encoded><![CDATA[<div
id="attachment_731" class="wp-caption alignleft" style="width: 310px"><a
href="http://house-tiere.de/wp-content/uploads/progressbar1.jpeg" rel="lightbox[723]"><img
class="size-medium wp-image-731" title="Advanced ProgressBar" src="http://house-tiere.de/wp-content/uploads/progressbar1-300x169.jpg" alt="Advanced Fortschrittsanzeige" width="300" height="169" /></a><p
class="wp-caption-text">Erweiterte Watibar</p></div><p>In Matlab fängt man mit <em>Progressbars</em> eigentlich recht simpel an. Und dann wirds größer und man will Informationen unterbringen, zum Beispiel wieviel Zeit vergangen ist, wieviel noch verbleibt, diverse Zwischenstände. Und wenn erst einmal für eine Funktion eine solche komplexe <em>Waitbar</em> erstellt hat, möchte man sie auch weiterverwenden, austauschen, konfigurieren, etc.</p><p>Wie man das recht gut, objekt-orientiert und elegant mit <em>Event-Listeners</em> in Matlab realisieren kann, versuche ich mal im Folgenden an Hand eines simplen Beispiels zu demonstrieren&#8230;<span
id="more-723"></span><br
/> Matlab bringt bereits eine recht einfache, aber gute <em>Fortschrittsanzeige</em> mit, die mit <code>waitbar</code> aufgerufen wird, und für jede Iteration aktualisiert werden kann.</p><p>Man hätte also in etwa mit folgenden Code eine schnelle, schlanke Lösung</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">for</span> r=<span style="color: #33f;">1</span>:obj.<span style="">rounds</span>
   obj.<span style="">performance</span> = obj.<span style="">computePerformance</span>;
   <span style="color: #0000FF;">waitbar</span><span style="color: #080;">&#40;</span>r/obj.<span style="">rounds</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Für einfache, wirklich kurze Programme funktioniert das sehr gut. Aber man wird schon relativ häufig feststellen, dass Programme sehr schnell unübersichtlich und groß werden. Und hier wird man schnell einige Nachteile dieses Vorgehens feststellen:</p><ul><li>Man erweitert die Waitbar um weitere Inhalte (z.B. abgelaufene Zeit) und hat recht komplexen Code. Dabei möchte man diese Progress-Bar vielleicht auch für andere Vorgänge nutzen &#8211; man möchte aber<strong> redundanten Code vermeiden</strong></li><li>Man möchte die Waitbar gegen eine andere <strong>austauschen</strong>, oder statt einer GUI-basierten Fortschrittsanzeige eine textuelle Ausgabe, wenn man die Funktion per Kommandozeile auruft &#8211; Oder beides gleichzeitig, oder komplett deaktivieren&#8230;</li><li>Die Funktion, die die Schleife ausführt soll eigentlich nicht GUI-Dinge, Benutzerausgaben abwickeln. Außerdem macht der zusätzliche Code die Funktion <strong>unleserlich</strong> &#8211; Es scheint irgendwie intuitiv nicht richtig so, es sollte <strong>gekappselt</strong> sein.</li></ul><p>Was man hier möchte ist eine seperate Funktion, die benachrichtigt wird bei jedem Schleifendurchlauf, um einen Fortschrittsbalken (welcher Art auch immer) zu aktualisieren. Und die eigentlich Funktion hat nichts weiter mit der Realisierung zu tun, außer ein solches <em>notify</em> zu senden.</p><p>Das sind <strong>Events</strong> und<strong> Eventlistener</strong>. Und sowas gibts schon in Matlab &#8211; sofern man <em>objekt-orientiert </em>entwickelt. Folgendes Beispiel demonstriert die Funktionsweise &#8211; der Cycler ist ein Objet, dass eine bestimmte Operation iteriert, und eine Performance berechnet:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">classdef cycler &lt; handle
&nbsp;
    properties <span style="color: #080;">&#40;</span>SetAccess = protected<span style="color: #080;">&#41;</span>
        rounds = <span style="color: #33f;">20</span>;
    <span style="color: #0000FF;">end</span>
&nbsp;
    properties <span style="color: #080;">&#40;</span>GetAccess = public<span style="color: #080;">&#41;</span>
        performance = <span style="color: #33f;">0</span>;
        actualRound;
    <span style="color: #0000FF;">end</span>
&nbsp;
    events
        cycle;
    <span style="color: #0000FF;">end</span>
&nbsp;
    methods
&nbsp;
        <span style="color: #0000FF;">function</span> rounds = getRoundCount<span style="color: #080;">&#40;</span>obj<span style="color: #080;">&#41;</span>
           rounds = obj.<span style="">rounds</span>;
        <span style="color: #0000FF;">end</span>
&nbsp;
        <span style="color: #0000FF;">function</span> runCycles<span style="color: #080;">&#40;</span>obj<span style="color: #080;">&#41;</span>
            <span style="color: #0000FF;">for</span> r=<span style="color: #33f;">1</span>:obj.<span style="">rounds</span>
                obj.<span style="">performance</span> = obj.<span style="">computePerformance</span>;
                obj.<span style="">actualRound</span> = r;
                notify<span style="color: #080;">&#40;</span>obj,<span style="color:#A020F0;">'cycle'</span><span style="color: #080;">&#41;</span>;
            <span style="color: #0000FF;">end</span>
        <span style="color: #0000FF;">end</span>
&nbsp;
        <span style="color: #0000FF;">function</span> perf = computePerformance<span style="color: #080;">&#40;</span>obj<span style="color: #080;">&#41;</span>
            <span style="color: #228B22;">% some magic calculation</span>
            <span style="color: #0000FF;">pause</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0.35</span><span style="color: #080;">&#41;</span>
            perf = <span style="color: #0000FF;">rand</span>;
        <span style="color: #0000FF;">end</span>
    <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Zunächst kommt eine Reihe von <em>Properties</em>. Zum Beispiel soll auch die aktuell laufende Runde in einer Variable abgelegt werden, die man zum Beispiel auch für die Progressbar als zusätzliche Information nutzen könnte.<br
/> Interessanter sind hier <code>events</code>. In diesem Fall gibt es nur ein Event: <code>cycle</code>. Es soll nach jeder Iteration ein Event <code>cycle</code> gesendet werden. Und das ganze passiert in der Methode <code>runCycles</code>. Diese Schleife sieht genauso aus wie in dem simplen Beispiel oben, aber mit dem Unterschied:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">notify<span style="color: #080;">&#40;</span>obj,<span style="color:#A020F0;">'cycle'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Hier wird einfach nur ein <code>notify</code> auf dem Objekt aufgerufen.<br
/> Nur schauen wir uns an, wie man eine solche Waitbar realisieren kann:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">classdef CyclerProgressBar &lt; handle
&nbsp;
    properties <span style="color: #080;">&#40;</span>SetAccess = protected<span style="color: #080;">&#41;</span>
        Start;
        h;
    <span style="color: #0000FF;">end</span>
&nbsp;
   methods
      <span style="color: #0000FF;">function</span> obj = CyclerProgressBar<span style="color: #080;">&#40;</span>cycler_obj<span style="color: #080;">&#41;</span>
         obj.<span style="">h</span> = <span style="color: #0000FF;">waitbar</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>, <span style="color:#A020F0;">'Please Wait'</span>, <span style="color:#A020F0;">'Name'</span>, <span style="color:#A020F0;">'Running Cycles'</span><span style="color: #080;">&#41;</span>;
         posi = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>obj.<span style="">h</span>,<span style="color:#A020F0;">'Position'</span><span style="color: #080;">&#41;</span>;
         posi<span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> = posi<span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> + <span style="color: #33f;">100</span>;
         <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>obj.<span style="">h</span>,<span style="color:#A020F0;">'Position'</span>,posi<span style="color: #080;">&#41;</span>;
         addlistener<span style="color: #080;">&#40;</span>cycler_obj, <span style="color:#A020F0;">'cycle'</span>,@<span style="color: #080;">&#40;</span>src,evtdata<span style="color: #080;">&#41;</span>handleEvnt<span style="color: #080;">&#40;</span>obj,src,evtdata<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
         obj.<span style="">Start</span> = <span style="color: #0000FF;">tic</span>;
      <span style="color: #0000FF;">end</span>
&nbsp;
      <span style="color: #0000FF;">function</span> <span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>obj<span style="color: #080;">&#41;</span>
         <span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>obj.<span style="">h</span><span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
&nbsp;
      <span style="color: #0000FF;">function</span> handleEvnt<span style="color: #080;">&#40;</span>obj,src,evtdata<span style="color: #080;">&#41;</span>
           timer = <span style="color: #0000FF;">toc</span><span style="color: #080;">&#40;</span>obj.<span style="">Start</span><span style="color: #080;">&#41;</span>;
           obj.<span style="">h</span> = <span style="color: #0000FF;">waitbar</span><span style="color: #080;">&#40;</span>src.<span style="">actualRound</span>/src.<span style="">getRoundCount</span>, obj.<span style="">h</span>, <span style="color: #080;">...</span>
           <span style="color: #0000FF;">sprintf</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Validation Round %d (%d)\n\n Performance:\nThis iteration: %3.1f  %%\n\nTime: \nRemaining: %4.0f sec. - Elapsed: %4.0f sec.\n\n'</span>,<span style="color: #080;">...</span>
           <span style="">src</span>.<span style="">actualRound</span>, src.<span style="">getRoundCount</span>, <span style="color: #080;">...</span>
           <span style="">src</span>.<span style="">performance</span>*<span style="color: #33f;">100</span>,<span style="color: #080;">...</span>
           <span style="color: #080;">&#40;</span>timer/src.<span style="">actualRound</span><span style="color: #080;">&#41;</span>*<span style="color: #080;">&#40;</span>src.<span style="">getRoundCount</span>-src.<span style="">actualRound</span><span style="color: #080;">&#41;</span>, timer<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>
<span style="color: #0000FF;">end</span></pre></div></div><p>Der <em>Konstruktor</em> erstellt direkt die in Matlab gewohnte Waitbar (man könnte dies evlt. auch später machen oder über eine seperate Funktion). Um nun in der Waitbar mehrere Zeilen Text unterbringen zu können, vergrößert man diese mittels GUI-Properties:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">         posi = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>obj.<span style="">h</span>,<span style="color:#A020F0;">'Position'</span><span style="color: #080;">&#41;</span>;
         posi<span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> = posi<span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span> + <span style="color: #33f;">100</span>;
         <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>obj.<span style="">h</span>,<span style="color:#A020F0;">'Position'</span>,posi<span style="color: #080;">&#41;</span>;</pre></div></div><p>Der Konstruktor bekommt direkt das Objekt mit übergeben, auf das er horchen soll. Ein bißchen tricky war in diesem die Funktion <code>addListener</code> zu modifizieren, damit die Progressbar sich aus dem Objekt, auf das es horcht, weitere Informationen (wie z.B. Performance) ziehen kann und diese mit ausgibt. Wenn man einen Blick in die Beispiele der Matlab-Doku wirft, findet man meist so etwas hier:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">addlistener<span style="color: #080;">&#40;</span>toggle_button_obj,<span style="color:#A020F0;">'ToggledState'</span>,@RespondToToggle.<span style="">handleEvnt</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Was ich eigentlich wollte, ist das Objekt (oder etwas anderes) mit übergeben. Hierfür macht man sich die Funktionaltität anonymer Funktionen zu nutze:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">addlistener<span style="color: #080;">&#40;</span>cycler_obj, <span style="color:#A020F0;">'cycle'</span>,@<span style="color: #080;">&#40;</span>src,evtdata<span style="color: #080;">&#41;</span>handleEvnt<span style="color: #080;">&#40;</span>obj,src,evtdata<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Nun kann die Funktion <code>handleEvent</code> das Objekt, dass das <code>notify</code> ausführt, mit übergeben bekommen.<br
/> in Timer mit wird mittels <code>tic</code> zum einen Timer gestartet und die Startzeit abgelegt, damit wäre der Konstruktor fertig.<br
/> Bei jedem <code>notify</code> wird nun <code>handleEvent</code> aufgerufen. Dabei checkt man mit <code>toc</code> die abelaufene Zeit. Und nun kann ich mit Hilfe von <code>sprintf</code> und weil ich das Waitbar-Fenster vergrößert habe, jede Menge Informationen ausgeben, wie Uhrzeit und Performance.<br
/> Der <em>EventListener</em> muss nun nur noch registiert werden:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">demoCycler = cycler;
demoBar = CyclerProgressBar<span style="color: #080;">&#40;</span>demoCycler<span style="color: #080;">&#41;</span>;
demoCycler.<span style="">runCycles</span>;
<span style="color: #0000FF;">delete</span><span style="color: #080;">&#40;</span>demoBar<span style="color: #080;">&#41;</span>;</pre></div></div><p>Denkbar wären, wie bereits zuvor erwähnt, nun auch weitere Progressbars, die anderen Text enthalten, oder eine zusätzliche textuelle Ausgabe (was ich mal aus Faulheit hier jetzt nicht mehr gecodet habe <img
src='http://house-tiere.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p><p>Sicherlich sind Eventlistener in Matlab nicht so flexibel wie in Java, doch sie funktionieren wie in diesem Beispiel für einfach Dinge recht gut.</p><p>Das Beispiel zum Download:<br
/> <a
class="downloadlink" href="http://house-tiere.de/wp-content/plugins/download-monitor/download.php?id=11" title="Version1 heruntergeladen 69 mal" >AdvancedWaitbarSample (69)</a></p> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/scripts/flexible-erweiterte-progressbar-in-matlab-mit-event-listener/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Zeilenumbruch in Tooltips &#8211; Matlab GUI</title><link>http://house-tiere.de/scripts/zeilenumbruch-in-tooltips-matlab-gui/</link> <comments>http://house-tiere.de/scripts/zeilenumbruch-in-tooltips-matlab-gui/#comments</comments> <pubDate>Sat, 17 Apr 2010 01:46:53 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Scripts]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[GUIDE]]></category> <category><![CDATA[html]]></category> <category><![CDATA[Java]]></category> <category><![CDATA[matlab]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=552</guid> <description><![CDATA[Zeilenumbrüche in Tooltips bei Matlab GUIs einfügen &#8211; Wie macht man das? Vor dem Problem stand ich eben, als ich mit GUIDE dabei war eine kleine GUI zu verfeineren. &#8220;\n&#8221; funktioniert übrigens nicht . Was aber funktioniert ist html, es gibt ein undokumentiertes Feautre, mit dem einfach html eingefügt werden kann &#8211; Java machts möglich. [...]]]></description> <content:encoded><![CDATA[<p>Zeilenumbrüche in Tooltips bei Matlab GUIs einfügen &#8211; Wie macht man das? Vor dem Problem stand ich eben, als ich mit <em>GUIDE</em> dabei war eine kleine GUI zu verfeineren. &#8220;\n&#8221; funktioniert übrigens nicht <img
src='http://house-tiere.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Was aber funktioniert ist <em>html</em>, es gibt ein <a
href="http://undocumentedmatlab.com/blog/spicing-up-matlab-uicontrol-tooltips/">undokumentiertes Feautre</a>, mit dem einfach html eingefügt werden kann &#8211; Java machts möglich.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">string = <span style="color:#A020F0;">'&lt;html&gt;Nicht nur Zeilenumbrüche&lt;br&gt;sondern zum Beispiel auch &lt;b&gt;fett&lt;/b&gt; ist möglich&lt;/html&gt;'</span>;</pre></div></div><p>Aber das ist noch nicht alles, das ganze funktioniert nicht nur mit Tooltips, sondern auch mit den meisten andern GUI-Objekten, wie z.B.<em> listbox</em> oder Buttons. Nur mit StaticText, also simplen Labels, geht es wohl nicht. Dabei ist es unerheblich, ob man die GUI im Editor schreibt oder mit GUIDE die Werte setzt.</p><p>Und kurz nachgedacht, wenn das ganze html ist, ja, dann kann man auch Bilder und jede Menge anderen Unfug damit einbinden, z.B. einen Button mit einem Bild versehen.</p> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/scripts/zeilenumbruch-in-tooltips-matlab-gui/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Beschriftete Balkendiagramme in Matlab</title><link>http://house-tiere.de/allgemeines/beschriftete-balkendiagramme-in-matlab/</link> <comments>http://house-tiere.de/allgemeines/beschriftete-balkendiagramme-in-matlab/#comments</comments> <pubDate>Thu, 30 Jul 2009 19:30:48 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Allgemeines]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[Diagramme]]></category> <category><![CDATA[matlab]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=361</guid> <description><![CDATA[Wer viel mit Matlab rechnet und viele Daten generiert, möchte diese auch gerne auswerten &#8211; ich zum Beispiel mit Balkendiagrammen. Gut dabei ist, dass man mit Matlab auch über Scripte Diagramme und Figures erstellen kann. Schlecht ist &#8211; mal abgesehen davon, dass die vielen vielen Optionen nicht ganz trivial sind &#8211; dass nicht alle Funktionen [...]]]></description> <content:encoded><![CDATA[<p>Wer viel mit Matlab rechnet und viele Daten generiert, möchte diese auch gerne auswerten &#8211; ich zum Beispiel mit Balkendiagrammen. Gut dabei ist, dass man mit Matlab auch über Scripte Diagramme und Figures erstellen kann. Schlecht ist &#8211; mal abgesehen davon, dass die vielen vielen Optionen nicht ganz trivial sind &#8211; dass nicht alle Funktionen ausgereift sind und einem nicht immer die Funktionalität bieten, die man zum Beispiel von anderen Programmen wie gnuplot, OpenOffice Spreadsheet gewohnt ist.<br
/> <span
id="more-361"></span></p><p>So musste ich leider feststellen, dass es zwar die Möglichkeit gibt, Balkendiagramme in Matlab zu erstellen, aber eine Annotierung der x- und y-Achsenwerte beschränkt sich auf Zahlen, und ist nicht &#8211; wie ich es gern hätte &#8211; auf Strings erweiterbar ist. Das ganze läßt sich mit einem kleinen dirty fix umgehen, in dem man einfach &#8220;leere&#8221; Boxplots zusätzlich verwendet, die eine solche Art von Beschriftung unterstützen. Hier ein Matlab-Beispiel für ein horizontales Balkendiagramm:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">g_ = <span style="color: #0000FF;">clf</span>;
<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span>g_<span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% ABCdescription enthält Strings: Beschreibungen für Gruppen von Werten A B C (A B C müssen gleich groß sein)</span>
<span style="color: #228B22;">% zeros - 1 sorgt dafür, dass alle Werte -1 für die Boxplots.</span>
boxplot<span style="color: #080;">&#40;</span><span style="color: #0000FF;">zeros</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">size</span><span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> - <span style="color: #33f;">1</span>, ABCdescription, <span style="color:#A020F0;">'orientation'</span>, <span style="color:#A020F0;">'horizontal'</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% Balkendiagramm horizontal mit barh</span>
<span style="color: #0000FF;">barh</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span>A, B, C ,<span style="color:#A020F0;">'group'</span><span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">% Anpassen der x-Achse, z.B. nur Werte von 0 bis 1 -&gt; die Boxplots bei -1 sind nicht mehr sichtbar.</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gca</span>,<span style="color:#A020F0;">'xlim'</span>,<span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">1</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">legend</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'A'</span>,<span style="color:#A020F0;">'B'</span>,<span style="color:#A020F0;">'C'</span><span style="color: #080;">&#41;</span>;
leginfo_ = <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Orientation'</span>, <span style="color:#A020F0;">'vertical'</span>, <span style="color:#A020F0;">'Location'</span>, <span style="color:#A020F0;">'NorthWest'</span><span style="color: #080;">&#125;</span>;
<span style="color: #0000FF;">legend</span><span style="color: #080;">&#40;</span>leginfo_<span style="color: #080;">&#123;</span>:<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% create legend</span>
<span style="color: #228B22;">% nach Bedarf abspeichern und schließen</span>
<span style="color: #0000FF;">saveas</span><span style="color: #080;">&#40;</span>g_, <span style="color:#A020F0;">'myABC'</span>, <span style="color:#A020F0;">'png'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">close</span><span style="color: #080;">&#40;</span>g_<span style="color: #080;">&#41;</span>;</pre></div></div> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/allgemeines/beschriftete-balkendiagramme-in-matlab/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Neuronale Netze und Matlab</title><link>http://house-tiere.de/bioinformatik/neuronale-netze-und-matlab/</link> <comments>http://house-tiere.de/bioinformatik/neuronale-netze-und-matlab/#comments</comments> <pubDate>Thu, 30 Jul 2009 16:10:13 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Bioinformatik]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[künstliche Intelligenz]]></category> <category><![CDATA[matlab]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=348</guid> <description><![CDATA[In meinem Bio-Seminar, wo ein neuronales Netz entwickelt werden sollte, hab ich mich intensiv mit der Neural Network Toolbox in Matlab beschäftigt. Dieser Teil der Matlab Bioinformatic Tools ermöglicht einem relativ schnell und einfach ein neuronales Netz zur Mustererkennung zu entwickeln. Auf den ersten Blick scheint es zwar ein wenig verwirrend, aber hat man sich [...]]]></description> <content:encoded><![CDATA[<p>In meinem Bio-Seminar, wo ein neuronales Netz entwickelt werden sollte, hab ich mich intensiv mit der <em>Neural Network Toolbox</em> in <a
href="http://www.mathworks.com/products/neuralnet/">Matlab</a> beschäftigt. Dieser Teil der <em>Matlab Bioinformatic Tools </em>ermöglicht einem relativ schnell und einfach ein neuronales Netz zur Mustererkennung zu entwickeln. Auf den ersten Blick scheint es zwar ein wenig verwirrend, aber hat man sich erstmal eingearbeitet sind Modifikationen an Neuronalen Netz, Netztyp, Trainingsparameter etc. relativ leicht zu bewerkstelligen.<span
id="more-348"></span></p><p>Man braucht zunächst eine Matrix mit Trainingsmustern. Ein einzelnes Muster besteht aus einem Vektor, die Vektoren zusammen ergeben dann die Muster-Matrix. Zu jedem Muster gehört zusätzlich eine Klassifizierung, bei binären Problemen (&#8220;Ist vom Muster vom A oder B?&#8221;) ist dies im Allgemeinen 1 oder 0. Somit hat man als Zielmatrix einen transponierten Vektor, für jedes Muster ein Klassifizierungswert 1 oder 0. Eine neue Instanz eine neuronalen Netzes erhält man durch:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">net = newff<span style="color: #080;">&#40;</span>MusterMatrix,ZielMatrix, <span style="color: #080;">&#91;</span><span style="color: #33f;">10</span> <span style="color: #33f;">2</span><span style="color: #080;">&#93;</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'logsig'</span>,<span style="color:#A020F0;">'logsig'</span><span style="color: #080;">&#125;</span>,<span style="color:#A020F0;">'trainrp'</span>,<span style="color:#A020F0;">'learngdm'</span>,<span style="color:#A020F0;">'mse'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Die ersten beiden Parameter geben somit die Muster und ihre Klassifizierung an. Man kann hierfür auch zusätzlich die Testdaten nehmen, die Muster werden in diesem Schritt nur benötigt, um die Größe der Eingabeschicht zu ermitteln, Werte zu normalisieren und eventuell die Koordinate, für die Werte in jedem Muster gleich ist, zu ignorieren (in diesem Fall wird keine Verbindung zur verdeckten Schicht erstellt).<br
/> Der dritte Paramter ist ein Zeilenvektor, in diesem Beispiel (10 2). dieser spezifiziert die Anzahl der verdeckten Schichten. Eingabeschicht und Ausgabeschicht werden wie bereits erwähnt automatisch anhand der Muster und der Sollklassifizierung ermittelt. Mit (10, 2) würde man zum Beispiel 2 verdeckte Schichten mit 10 bzw. 2 Neuronen erstellen.<br
/> Der nächste Parmater ist ein Cellarray und spezifiziert die zu nutzende <a
href="http://de.wikipedia.org/wiki/Aktivierungsfunktion#Aktivierungsfunktionen"><em>Aktivierungsfunktion</em></a> für jedes Netz. Die logistische Funktion (<em>logsig</em>) ist meist die Regel bei neuroanlen Netzen.<br
/> Dann folgenden noch 3 Strings, die Trainingsfunktion, die Lernfunktion und die Fehlerfunktion, am gebräuchlichsten ist wohl der mittlere quadratische Fehler (<em>mse</em>). Als Trainingsfunktion bevorzuge ich persönliche <a
href="http://de.wikipedia.org/wiki/Resilient_Propagation">Resilient Backpropagation</a> (<em>trainrp</em>), sie bezieht die Historie des Fehlergradienten mit ein und ist in der Regel performanter als <a
href="http://de.wikipedia.org/wiki/Backpropagation">Standard-Backpropagation</a>. Standardmäßig ist die Trainingsfunktion in der Toolbox jedoch Levenberg-Marquardt Backpropagation (<em>trainlm</em>).<br
/> Damit hat man ein Netz erstellt, dass nun trainiert werden soll, dazu benutzt man ganz einfach train:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">net = train<span style="color: #080;">&#40;</span>net,MusterMatrix,ZielMatrix<span style="color: #080;">&#41;</span>;</pre></div></div><p>Dabei sollte man natürlich nur Trainingsdaten nehmen. Es öffnet sich ein Fenster, dass Fortschritt und Performanz in jeder Iteration anzeigt. Anschließend kann man das Netz testen, oder für einzelne Muster auswerten:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">out = sim<span style="color: #080;">&#40;</span>net, TestDaten<span style="color: #080;">&#41;</span>;</pre></div></div><p><em>out</em> enthält anschließend vorhergesagte Werte.<br
/> Vor dem Training kann man auch noch einige Anpassungen vornehmen, z.B.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">net.<span style="">trainParam</span>.<span style="">showWindow</span> = <span style="color: #33f;">0</span>; <span style="color: #228B22;">% Gui nicht anzeigen, hilfreich bei automatischen tests</span>
net.<span style="">trainParam</span>.<span style="">lr</span> = <span style="color: #33f;">0.1</span>;              <span style="color: #228B22;">% Lernarte ändern</span>
net.<span style="">trainParam</span>.<span style="">epochs</span> = <span style="color: #33f;">100</span>;      <span style="color: #228B22;">% Anzahl der Trainigsdurchläufe</span>
net.<span style="">trainParam</span>.<span style="">goal</span> = 1e-3;         <span style="color: #228B22;">% Abbruchbedingung bezüglich Fehler</span></pre></div></div><p>Auch für das Netz kann man zahlreiche Änderungen vornehmen, wenn man zum Beispiel nicht will, dass gleiche Werte in den Mustern ignoriert werden und trotzdem Verbindungen zur verdeckten Schicht erstellt werden, kann mal folgendes machen:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">ipf = <span style="color: #080;">&#123;</span><span style="color: #080;">&#125;</span>;
tpf = <span style="color: #080;">&#123;</span><span style="color: #080;">&#125;</span>;
ddf = <span style="color:#A020F0;">'dividerand'</span>;
net = newff<span style="color: #080;">&#40;</span>MusterMatrix,ZielMatrix, <span style="color: #080;">&#91;</span><span style="color: #33f;">10</span> <span style="color: #33f;">2</span><span style="color: #080;">&#93;</span>, <span style="color: #080;">&#123;</span><span style="color:#A020F0;">'logsig'</span>,<span style="color:#A020F0;">'logsig'</span><span style="color: #080;">&#125;</span>,<span style="color:#A020F0;">'trainrp'</span>,<span style="color:#A020F0;">'learngdm'</span>,<span style="color:#A020F0;">'mse'</span>,ipf,tpf,ddf<span style="color: #080;">&#41;</span>;</pre></div></div><p>Zur Bestimmung der Qualität erstellter Netze gibt es noch einige weitere Tools, Stichwort<em> rocplot</em>.<br
/> Kleiner Wehrmutstropfen ist, dass die Neural Network Toolbox manchmal sehr knapp dokumentiert ist, vor allem wenn es um kleine Parameter geht. Auch google hilft einem nicht immer weiter. Oft hilft nur probieren und mal in den Quellcode schauen.<br
/> Nichts desto trotz ist es eine mächtige Toolbox, man kann viele Netzarten und -architekturen realisieren, wie z.B. <a
href="http://de.wikipedia.org/wiki/Time_Delay_Neural_Network">Input-Time-Deay-Netze</a>, <a
href="http://de.wikipedia.org/wiki/Elman-Netz">Elman-Netze</a>, rekurrente Netze. Und dabei kann man vieles selber nach eigenen Bedürfnissen anpassen, ohne dass man eine komplett neue Software schreiben muss.</p> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/bioinformatik/neuronale-netze-und-matlab/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Grub: Dualboot Windows XP &#8211; ohne Linux</title><link>http://house-tiere.de/allgemeines/grub-dualboot-windows-xp-ohne-linux/</link> <comments>http://house-tiere.de/allgemeines/grub-dualboot-windows-xp-ohne-linux/#comments</comments> <pubDate>Tue, 19 May 2009 20:22:11 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Allgemeines]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[script]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=256</guid> <description><![CDATA[Sollte man mal in der Situation sein, 2 Windows XP Partitionen zu benötigen, stellt sich die Frage, mit welchem Bootloader man das realisieren will. Eine Möglichkeiten einer solchen dualen Windows-Installation lässt sich mit Grub realisieren, es ist nicht wirklich besonders schwer. Vielleicht gibt es noch andere Möglichkeiten, aber ich hab nun mal grub ausprobiert, und [...]]]></description> <content:encoded><![CDATA[<p>Sollte man mal in der Situation sein, 2 Windows XP Partitionen zu benötigen, stellt sich die Frage, mit welchem Bootloader man das realisieren will. Eine Möglichkeiten einer solchen dualen Windows-Installation lässt sich mit Grub realisieren, es ist nicht wirklich besonders schwer. Vielleicht gibt es noch andere Möglichkeiten, aber ich hab nun mal grub ausprobiert, und das tat ganz gut. Und wer glaubt grub benötigt ein Linux, der irrt, das ganze geht auch ohne.<br
/> <span
id="more-256"></span><br
/> Sofern man nicht vor der Installation auf eine vernünftige Partitionierung geachtet hat, muss man diese eventuell noch anpassen. In den meisten Fällen wird man &#8211; davon geh ich mal aus &#8211; schon ein fertig installiertes Windows XP besitzen und will eventuell ein weiteres Windows XP hinzufügen (oder 2000, 98 etc&#8230;). Nun muss man noch Platz schaffen, am besten mit einer Live-CD (<a
href="http://www.knoppix.org/">Knoppix</a>, <a
href="http://www.ubuntu.com/getubuntu/download">Ubuntu</a>, o.ä.) eben booten und die alte Partition verkleinern, z.B. mit gparted oder qtparted. Es empfiehlt sich vorher ein Backup der Partition, falls was schief geht! Anschließend legt man eine neue <em>ntfs</em>-Partition an und lässt noch ein wenig Platz für eine <em>ext3</em>-Partition, auf die später noch grub ein paar dateien ablegt (in <em>/boot/grub/</em>). Für die grub-Partition sind 100 bis 200 MB mehr als ausreichend.</p><p>Nun ist es an der Zeit, auf der neuen <em>ntfs</em>-Partition ganz normal das zweite Windows XP zu installieren. Dadurch wird natürlich die alte Windows-Partition erstmal nicht mehr bootbar. Nachdem man da alles soweit installiert und eventuell upgedated hat, bootet man erneut mit einer Live-CD, der nächste Schritt ist die Installation von grub.</p><p>Die folgenden Aktionen sind als root-user bzw. mit <em>sudo</em> durchzuführen. Zunächst wird die ca. 100 MB große <em>ext3</em>-Partition (in diesem Beispiel <em>sda4</em>) gemountet:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>tempgrub
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda4 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>tempgrub</pre></div></div><p>und anschließend grub installiert:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">grub-install <span style="color: #660033;">--root-directory</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>tempgrub<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda4</pre></div></div><p>Nun muss noch eine menu.lst angelegt werden in /mnt/tempgrub/boot/grub/ &#8211; mit Einträgen in etwa so:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">timeout <span style="color: #000000;">60</span>
default <span style="color: #000000;">0</span>
&nbsp;
title Windows XP - I
unhide <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
hide <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
rootnoverify <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
makeactive
chainloader +<span style="color: #000000;">1</span>
&nbsp;
title Windows XP - II
unhide <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
hide <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
rootnoverify <span style="color: #7a0874; font-weight: bold;">&#40;</span>hd0,<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
makeactive
chainloader +<span style="color: #000000;">1</span></pre></div></div><p>Wobei <em>(hd0,x) </em>jeweils für x-te Partition steht (bei <em>sda</em> muss man immer eins dazuzählen). <em>hide</em> und <em>unhide</em> verstecken die jeweilige andere Windows-Partition, die grad nicht genutzt wird. Besonders acht sollte man auf Leerzeichen zwsichen <em>hide</em> und (<em>hda</em>..) geben, sonst gibts Fehler in der Form:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">Grub Error <span style="color: #000000;">13</span>: <span style="color: #ff0000;">&quot;Invalid or unsupported executable format&quot;</span></pre></div></div><p>Zur Sicherheit noch einmal wiederholen, damit auch grub up to date ist:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">grub-install <span style="color: #660033;">--root-directory</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>tempgrub<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda4</pre></div></div><p>Und beim nächsten Reboot sollte man dann in der Lage sein, zwischen den beiden Windows XP Partitionen zu wählen. Das ganze sollte auch mit Windows Vista funktionieren &#8211; wobei Vista -afaik- nen eigenen bootloader hat, damit sollte es natürlich auch schon so gehen.</p> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/allgemeines/grub-dualboot-windows-xp-ohne-linux/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>gnuplot: Box-Whisker-Plot</title><link>http://house-tiere.de/allgemeines/gnuplot-box-whisker-plot/</link> <comments>http://house-tiere.de/allgemeines/gnuplot-box-whisker-plot/#comments</comments> <pubDate>Sun, 03 May 2009 15:02:59 +0000</pubDate> <dc:creator>Woody</dc:creator> <category><![CDATA[Allgemeines]]></category> <category><![CDATA[Scripts]]></category> <category><![CDATA[Grafik]]></category> <category><![CDATA[script]]></category> <guid
isPermaLink="false">http://house-tiere.de/?p=212</guid> <description><![CDATA[Als ich mit gnuplot vernünftige Boxplots, sogenannte Box-Whisker-Plots, erstellen wollte, fand ich keine nativen Funktionen dafür. Trotzdem hab ich für dieses Problem ein Workaround ausgemacht: Man legt einfach zwei Candelsticks übereinander, der zweite dient einfach nur als flache Markierung für den Median als eine schwarzer Linie. Fertig ist der Boxplot. Der Code sieht dann bei [...]]]></description> <content:encoded><![CDATA[<p>Als ich mit <a
href="http://www.gnuplot.info/">gnuplot</a> vernünftige Boxplots, sogenannte <em>Box-Whisker-Plots</em>, erstellen wollte, fand ich keine nativen Funktionen dafür. Trotzdem hab ich für dieses Problem ein Workaround ausgemacht: Man legt einfach zwei Candelsticks übereinander, der zweite dient einfach nur als flache Markierung für den Median als eine schwarzer Linie. Fertig ist der Boxplot. <img
src='http://house-tiere.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Der Code sieht dann bei mir etwa so aus:<span
id="more-212"></span></p><div
class="wp_syntax"><div
class="code"><pre class="gnuplot" style="font-family:monospace;"><span style="color: #b1b100;">set</span> <span style="color: #990000;">size</span> <span style="color: #cc66cc;">1.0</span><span style="color: #000; font-weight: bold;">,</span><span style="color: #cc66cc;">1.0</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">key</span> <span style="color: #448888;">box</span> <span style="color: #448888;">linestyle</span> <span style="color: #cc66cc;">1</span>
<span style="color: #b1b100;">set</span> auto <span style="color: #448888;">y</span>
<span style="color: #b1b100;">set</span> auto <span style="color: #448888;">x</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">terminal</span> <span style="color: #448888;">png</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">output</span> <span style="color: #0000ff;">&quot;myBoxPlot.png&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">title</span> <span style="color: #0000ff;">&quot;sample-boxplot&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">xlabel</span> <span style="color: #0000ff;">&quot;evolution&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">ylabel</span> <span style="color: #0000ff;">&quot;sequence relationen&quot;</span>
<span style="color: #b1b100;">set</span> <span style="color: #990000;">boxwidth</span> <span style="color: #cc66cc;">0.4</span>
<span style="color: #b1b100;">plot</span> <span style="color: #0000ff;">'tmp.plot'</span> <span style="color: #448888;">using</span> <span style="color: #cc66cc;">1</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">3</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">2</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">6</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">5</span> <span style="color: #448888;">with</span> <span style="color: #448888;">candlesticks</span> fs <span style="color: #448888;">solid</span> <span style="color: #cc66cc;">0.7</span> <span style="color: #990000;">title</span> <span style="color: #0000ff;">&quot;upper / under quartil&quot;</span><span style="color: #000; font-weight: bold;">,</span> \
<span style="color: #0000ff;">''</span> <span style="color: #448888;">using</span> <span style="color: #cc66cc;">1</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">4</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">4</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">4</span><span style="color: #000; font-weight: bold;">:</span><span style="color: #cc66cc;">4</span> <span style="color: #448888;">with</span> candlestick <span style="color: #448888;">lt</span> <span style="color: #000; font-weight: bold;">-</span><span style="color: #cc66cc;">1</span> fs <span style="color: #448888;">solid</span> <span style="color: #cc66cc;">1.0</span> <span style="color: #990000;">title</span> <span style="color: #0000ff;">&quot;median&quot;</span></pre></div></div><p>Wobei in den eingelesenen Daten der erste Eintrag den entsprechenden boxplot spezifiziert, gefolgt von unteres Quartil und Minimum, dann Maximum und oberes Quartil im 5. und 6. Eintrag. Der Median wird dann im nächsten Plot aus dem 4. Eintrag genommen und einfach als flacher Candlestick dargestellt. Damit lassen sich Boxplot dann auch schön automatisiert aus csv-Dateien mit gegebenen Quartil- und Median-Werten mit gnuplot zeichnen.<div
id="attachment_215" class="wp-caption alignleft" style="width: 310px"><img
class="size-medium wp-image-215" title="sample" src="http://house-tiere.de/wp-content/uploads/sample-300x225.png" alt="Beispiel Boxplot mit gnuplot" width="300" height="225" /><p
class="wp-caption-text">Beispiel Boxplot mit gnuplot</p></div><br
/> Nebenbei vielleicht noch einmal bemerkt, in einem geordneten Array sind Median genau in der Mitte, unteres und oberes Quartil an der 1/4- bzw. 3/4-Stelle des Arrays. Minimum und Maximum sind dann natürlich 1. und letztes Arrayelement. <img
src='http://house-tiere.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br
/> Es sieht nicht perfekt aus, und ein Nachteil ist auch, dass man keine Ausreißer darstellen kann. Aber gnuplot ist halt nur zum plotten und nicht berechnen. Naja, ich denke ich werd nächstes mal direkt was mit python und <a
href="http://www.r-project.org/">R</a> machen, weil das Rechnen in nem Shell-Script dann doch zu schnell zu aufwendig wird. Aber funktionieren tut es. Wenns nicht automatisiert sein muss, würd ichs sogar eher mit <a
href="http://projects.gnome.org/gnumeric/">gnumeric</a> machen.</p> ]]></content:encoded> <wfw:commentRss>http://house-tiere.de/allgemeines/gnuplot-box-whisker-plot/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
