<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>matlab &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/matlab/</link>
	<description>Feed of posts on WordPress.com tagged "matlab"</description>
	<pubDate>Mon, 07 Jul 2008 08:25:25 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Creating a Rotating Ellipse in Matlab]]></title>
<link>http://tabman.wordpress.com/?p=8</link>
<pubDate>Sun, 06 Jul 2008 15:42:19 +0000</pubDate>
<dc:creator>tabman</dc:creator>
<guid>http://tabman.wordpress.com/?p=8</guid>
<description><![CDATA[While working on some of research work I came across a situation where I wanted to generate a rotati]]></description>
<content:encoded><![CDATA[<p>While working on some of research work I came across a situation where I wanted to generate a rotating Ellipse in 2D whose point of rotation I should define myself. It turns out it is pretty simple to do. To learn about 2D rotation from Computer Vision perspective, see <a href="http:/http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm" target="_blank">this</a> link.</p>
<p>The most useful function in this code that I would like to mention is poly2mask. It is just an amazing function. What poly2mask would do is return you a binary image based on your region of interest and that region of interest is a polygon defined by set of points (vectors). In my case my polygon was a set of points connecting to form an Ellipse but if you understand the code then you can make any kind of rotating polygon using Matlab. Read the comments in the code and I guess you should be able to understand it.  Here is the prototype of the function call. The code generates a sequence of bmp files which were later converted to an mpeg video using imagemagick.</p>
<p>function [x,y] = generateEllipse(h, k, a, b,imageSize)</p>
<p>where h,k,a,b are standard notation for an Ellipse and imageSize is the size of an nxn output frame in which the Ellipse is going to rotate. Make sure to choose a big enough size which can accommodate an Ellipse white rotating</p>
<p>To watch the outcome from the code, see these videos:</p>
<p>Note the point of rotation in both videos.</p>
<p>Point of rotation is the centre:</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/CocoX0yixi8'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/CocoX0yixi8&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
<p> </p>
<p>Point of rotation is the left corner:</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/7Ik2StDwJ5o'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/7Ik2StDwJ5o&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
<p> </p>
<p>Using this code you can choose any point as "Point of Rotation" but make sure the point you choose lies inside the Ellipse. The code takes "Point of Rotation" output through the mouse using the Matlab function ginput and here is the code:</p>
<pre>function [x,y] = generateEllipse(h, k, a, b,imageSize) 

steps = 36;

%angle at which the Ellipse is initially located
atAngle = 0;

beta = atAngle / 180 * pi;
sinbeta = sin(beta);
cosbeta = cos(beta);

%we need to make a turn of 360 degrees to make a well formed Ellipse
i=1:360/steps:360;
alpha = i / 180 * pi;
sinalpha = sin(alpha);
cosalpha = cos(alpha);

%round function is important so as to store the points in the matrix
%the formula used is the parametric equation for Ellipse
x = round(h + (a * cosalpha * cosbeta - b * sinalpha * sinbeta)); 
y = round(k + (b * sinalpha * cosbeta + a * cosalpha * sinbeta));

%to connect with the line initial point so to make a connected Ellipse
x = [x,x(1)];
y = [y,y(1)];

bw = poly2mask(x,y,imageSize,imageSize);
imshow(bw);

 
%the user selects the point of rotation using the mouse

[rotationPointX rotationPointY] = ginput(1);
close

%translating the rotations points to origin

x1 = x-rotationPointX;
y1 = y-rotationPointY;

%the Ellipse will rotate ahead by 10 degree in each successive frame
rotationAngle = 10;

for index=0:299 %to generate 300 frames
    angle = mod(rotationAngle*index,360);
    %the equation for rotation

    newX = x1* cosd(angle) - y1*sind(angle); 
    newY = x1* sind(angle) + y1*cosd(angle);

    
    % return a binary image by masking the Ellipse region
    bw = poly2mask(newX+rotationPointX,newY+rotationPointY,imageSize,imageSize);
    figure
    imshow(bw);
    close

    fileName = sprintf('Ellipse1_frame_%s%04i.bmp', '', index)
    imwrite(bw,fileName);
end</pre>
<p><strong>The code was written in Matlab7.</strong></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[find: menemukan posisi matriks]]></title>
<link>http://orgawam.wordpress.com/?p=348</link>
<pubDate>Wed, 02 Jul 2008 08:06:43 +0000</pubDate>
<dc:creator>orgawam</dc:creator>
<guid>http://orgawam.wordpress.com/?p=348</guid>
<description><![CDATA[find
Menemukan posisi matriks (vektor) dengan nilai tak nol
Ada vektor dengan nilai komponen seperti]]></description>
<content:encoded><![CDATA[<p><strong>find</strong></p>
<p>Menemukan posisi matriks (vektor) dengan nilai tak nol</p>
<p>Ada vektor dengan nilai komponen seperti berikut,</p>
<p>&#62;&#62; X = [1 0 4 -3 0 0 0 8 6]<br />
<!--more--></p>
<p>X =</p>
<p>1     0     4    -3     0     0     0     8     6<br />
Nilai indeks ke 3 7 dan 1 ditentukan dengan perintah,</p>
<p>&#62;&#62; X([3 7 1])</p>
<p>ans =</p>
<p>4     0     1<br />
variabel indices menunjukkan <strong>posisi </strong>(indeks) matriks X yang mempunyai nilai tak nol</p>
<p>&#62;&#62; indices = find(X)</p>
<p>indices =</p>
<p>1     3     4     8     9</p>
<p><strong>posisi </strong>(indeks) matriks X dengan nilai lebih besar dari 2</p>
<p>&#62;&#62; find(X &#62; 2)</p>
<p>ans =</p>
<p>3     8     9<br />
<strong>posisi </strong>(indeks) matriks X dengan nilai sama dengan 0</p>
<p>&#62;&#62; find(X == 0)</p>
<p>ans =</p>
<p>2     5     6     7</p>
<p>Menampilkan nilai matriks X dengan nilai lebih besar dari 2</p>
<p>&#62;&#62; X(find(X &#62; 2))</p>
<p>ans =</p>
<p>4     8     6</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Swirl et fonctions de Bessel]]></title>
<link>http://fcontino.wordpress.com/?p=20</link>
<pubDate>Tue, 01 Jul 2008 13:59:54 +0000</pubDate>
<dc:creator>fcontino</dc:creator>
<guid>http://fcontino.wordpress.com/?p=20</guid>
<description><![CDATA[Par expériences, on a constaté que la respiration entraînait un swirl qui avait un profil radial ]]></description>
<content:encoded><![CDATA[<p>Par expériences, on a constaté que la respiration entraînait un swirl qui avait un profil radial qui suit une fonction paramétrisée de Bessel.<br />
Les pages suivantes parlent des fonctions de Bessel de manière générale <a href="http://www.vibrationdata.com/Bessel.htm">vibrationdata</a>,<a href="http://www.efunda.com/math/bessel/bessel.cfm">efunda</a> et <a href="http://en.wikipedia.org/wiki/Bessel_function">wikipedia</a><br />
<!--more--><br />
Dans le manuel de Kiva [1], une explication sommaire des paramètres qui définissent la fonction de Bessel fait référence à une publication de S. Wahiduzzaman et C. R. Ferguson [2]. Une autre publication donne quelques informations supplémentaires (<a href="http://www.arturo.derisi.unile.it/Dowloads/Pubblicazioni/ASME_ICE_2001.pdf">lien</a>) sans définir la fonction paramétrisée.</p>
<p>La fonction de Bessel utilisée est une fonction du premier type $latex J_n(x)$ avec n valant 1. Cette fonction présente deux points particuliers, elles s'annule en 0 et en 3.8317. Un paramètre alpha est rajouté pour modifier le profil de vitesse du fluide dans le cylindre. La vitesse azimutale peut donc s'écrire:</p>
<p>$latex v_{s} = C ~ J_1(\alpha\frac{r}{R})/\alpha$</p>
<p>où $latex C$ est une constante à définir, $latex r$ est le rayon où l'on souhaite connaître la vitesse et $latex R$ est le rayon maximal.</p>
<p>Dans les publications, on retrouve l'expression d'un "swirl ratio" qui correspond au rapport de la vitesse angulaire d'une roue représentant le fluide et de la vitesse angulaire du moteur.</p>
<p>$latex R_s = \frac{\omega_s}{2\pi ~ rpm/60}$</p>
<p>où $latex R_s$ est le ratio et $latex w_s$ est la vitesse angulaire de la "roue" représentant le fluide.</p>
<p>Il faut donc normalisé la fonction de Bessel en fonction de cette vitesse de rotation en posant que le moment angulaire est identique [1].</p>
<p>Le moment angulaire étant défini par</p>
<p>$latex L = \sum_i r_i v_i m_i$</p>
<p>où $latex m_i$ est la masse du volume élémentaire considéré. Dans le cas du cylindre, pour un élément d'angle et de hauteur (T et p uniforme lors de l'initialisation) cette masse élémentaire est proportionnelle au rayon et donc à une constante commune prêt:</p>
<p> $latex L \propto \sum_i v_i r_i^2$</p>
<p>On peut donc normaliser la vitesse azimutale en divisant celle-ci par la valeur de cette somme sur une valeur finie d'élément (typiquement 1000) sur le rayon. Le code matlab pour le calcul de la norme peut, par exemple, être</p>
<blockquote><p><code>norm = besselj(1,alpha*(0:0.001:1)) * ((0:0.001:1)'.^2) /alpha</code></p></blockquote>
<p>Des valeurs particulières du paramètre $latex \alpha$ sont représentées à la figure suivante (la valeur en ordonnée est normalisée par la valeur maximale de la vitesse de la "roue"):</p>
<p><a href="http://fcontino.files.wordpress.com/2008/07/bessel.png"></a><a href="http://fcontino.files.wordpress.com/2008/07/bessel1.png"><img class="alignnone size-medium wp-image-22" src="http://fcontino.wordpress.com/files/2008/07/bessel1.png?w=300" alt="Swirl pour certaines valeurs du paramètre alpha" width="300" height="225" /></a><br />
 </p>
<p>Il ne reste plus qu'à lier la valeur du swirl ratio avec la valeur réelle de la vitesse. Pour cela, il suffit de multiplier par $latex \omega_s ~ R$ et on obtient la valeur de la vitesse en fonction du rayon normalisé.</p>
<p>Références:</p>
<p>[1] A. A. Amsden, P. J. O’Rourke, T. D. Butler, "KIVA-II:  A Computer Program for Chemically Reactive Flows with Sprays", Los Alamos National Laboratory, 1989.</p>
<p>[2] S. Wahiduzzaman and C. R. Ferguson, “Convective Heat Transfer from a Decaying Swirling Flow within a Cylinder,” 8th International Heat Transfer Conference, paper #86-IHTC-253 (August 1986).</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[A legend used in the movie "The Happening"]]></title>
<link>http://autarkaw.wordpress.com/?p=34</link>
<pubDate>Fri, 27 Jun 2008 00:05:42 +0000</pubDate>
<dc:creator>Autar Kaw</dc:creator>
<guid>http://autarkaw.wordpress.com/?p=34</guid>
<description><![CDATA[Well M. Night Shyamalan may have made another disappointing movie - The Happening, but I somewhat li]]></description>
<content:encoded><![CDATA[<p>Well M. Night Shyamalan may have made another disappointing movie - <a href="http://www.mrqe.com/lookup?%5EHappening,+The+(2008)">The Happening</a>, but I somewhat liked it.  I would give it a grade of B.</p>
<p>In the movie, John Leguzomo's character, a math teacher, is distracting his fellow panicking passenger in the Jeep with a mathematical question.  The question he asks her is if he gave her a penny on Day 1 of the month, two pennies on Day 2 of the month, four pennies on Day 3 of the month, and so on, how much would money would she have after a month.  She shouts $300 or some odd number like that.  But, do you know that the amount is actually more than a 10 million dollars (Thanks to a student who mentioned that it was a penny that John offered on the first day, not a dollar - sometimes I do feel generous).</p>
<p>This question is based on a story from India and it goes as follows.</p>
<p>King Shriham of India wanted to reward his grand minister Ben for inventing the game of chess.  When asked what reward he wanted, Ben asked for 1 grain of rice on the first square of the board, 2 on the second square of the board, 4 on the third square of the board, 8 on the fourth square of the board, and so on till all the 64 squares were covered.  That is, he was doubling the number of grains on each successive square of the board.  Although Ben’s request looked less than modest, King Shriham quickly found that the amount of rice that Ben was asking for was humongous.</p>
<p><strong>QUESTIONS</strong>:</p>
<p>Write a MATLAB (you can use any other programming language) program for the following using the for or while loop.</p>
<ol>
<li>Find out how many grains of rice Ben was asking for.</li>
<li>If the mass of a grain of rice is 2 <em>mg</em>, and the world production of rice in recent years has been approximately 600,000,000 <em>tons</em> (1 ton=1000 kg), how many times the modern world production was Ben's request?</li>
<li>Do the inverse problem - find out how many squares are covered if the the number of grains on the chess board are given to you.  For example, how many squares will be covered if the number of grains on the chess board are 16?</li>
</ol>
<p><span style="color:#800000;">This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at <a href="http://numericalmethods.eng.usf.edu/">http://numericalmethods.eng.usf.edu</a></span></p>
<p><a href="http://feeds.feedburner.com/AutarkawsWeblog">Subscribe to the feed</a> to stay updated and let the information follow you.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Matlab in Linux]]></title>
<link>http://balajirrao.wordpress.com/?p=48</link>
<pubDate>Thu, 26 Jun 2008 10:56:48 +0000</pubDate>
<dc:creator>balajirrao</dc:creator>
<guid>http://balajirrao.wordpress.com/?p=48</guid>
<description><![CDATA[Here&#8217;s a nice way to run Matlab in Linux! Run windows in KVM, and run Matlab in windows, simpl]]></description>
<content:encoded><![CDATA[<p>Here's a nice way to run Matlab in Linux! Run windows in <a href="http://kvm.qumranet.com/kvmwiki">KVM</a>, and run Matlab in windows, simple! :)</p>
<p><a href="http://balajirrao.wordpress.com/files/2008/06/screenshot3.png"><img class="alignnone size-full wp-image-50" src="http://balajirrao.wordpress.com/files/2008/06/screenshot3.png" alt="Matlab in Linux" width="544" height="340" /></a></p>
<p><a href="http://balajirrao.wordpress.com/files/2008/06/screenshot2.png"><br />
</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Matlab]]></title>
<link>http://mesarunkumar.wordpress.com/?p=22</link>
<pubDate>Wed, 25 Jun 2008 20:04:37 +0000</pubDate>
<dc:creator>mearunkumars</dc:creator>
<guid>http://mesarunkumar.wordpress.com/?p=22</guid>
<description><![CDATA[Learning matlab !!!
Its fun unlike learning C,php,sql etc. which I am afraid of. My first experiment]]></description>
<content:encoded><![CDATA[<p>Learning matlab !!!</p>
<p>Its fun unlike learning C,php,sql etc. which I am afraid of. My first experiment started with the function magic() long ago long long ago when i was i first year. It was nice to identify the pattern of numbers for odd square matrices while had to break the head for the even dimensional matrices. Then the greed made me to go through the help to understand the code that they wrote (nice algo :P). It was then I found 3d plots very interesting and one day i sat to write a matrix (i forgot the dimentions of the matrix) to show A in the graph. Then I started playing with a lot of functions and started forgetting the older ones :(. You keep forgetting unless you dont use them in preactice. And today probably was the first time i used the functions for a proper use. And here is my first proper matlab file :).</p>
<p>Here is the code (any suggestions of improvement is welcome I'll learn frm them)</p>
<blockquote><p>function generation=game(m)<br />
%my first MATLAB problem statement is "GAME OF LIFE"<br />
temp=0;<br />
generation=0;<br />
X=round(rand(m,m));<br />
[i,j] = find(X);<br />
figure(gcf);<br />
plothandle = plot(i,j,'.', 'Color','blue');....this is nice way to write comment<br />
axis([0 m+1 0 m+1]);<br />
n = [m 1:m-1];<br />
e = [2:m 1];<br />
w = [m 1:m-1];<br />
s = [2:m 1];<br />
Z=0;<br />
while 1<br />
if((temp==0))<br />
Y=X;<br />
temp=1;<br />
elseif(temp==2)<br />
Z=X;<br />
temp=0;<br />
elseif(temp)<br />
temp=temp+1;<br />
end<br />
if(Z==Y)<br />
break<br />
end<br />
N = X(n,: ) + X(s,: ) + X(:,e) + X(:,w) + X(n,e) + X(n,w) + X(s,e) + X(s,w);<br />
X= (X &#38; (N == 2)) &#124; (N == 3);<br />
[i,j] = find(X);<br />
set(plothandle,'xdata',i,'ydata',j)<br />
drawnow<br />
generation=generation+1;<br />
end</p>
<p>%the number of generation i.e the answer returned is sometimes far less<br />
%than the actaul number of generations it takes to stabilize a population</p>
<p>%Also here the universe is circular which could be made flat by modifying<br />
%the values of news.</p></blockquote>
<blockquote><p>EOF</p></blockquote>
<p>Rules of Game Of Life</p>
<p>In the "Game of Life" the domain is a 2-dimensional array of cells, and each cell can have one of two possible states, usually referred to as "alive" or "dead." The array is usually intialized using random numbers and the system then evolves in time. At each time step, each cell may or may not change its state, based on the number of adjacent alive cells, including diagonals. There are three rules:</p>
<ol>
<li>If a cell has three neighbors that are alive, the cell will be alive. If it was already alive, it will remain so, and if it was dead, it will become alive.</li>
<li> If a cell has two neighbors that are alive, there is no change to the cell. If it was dead, it will remain dead, and if it was alive, it will remain alive.</li>
<li> In all other cases — the cell will be dead. If it was alive it becomes dead and if it was dead it remains dead.</li>
</ol>
<p><a title="M Files" href="http://nittstar.googlepages.com/matlabimages.zip" target="_blank">You can have a look at those images here if you have matlab</a></p>
<p><a title="jpeg files" href="http://nittstar.googlepages.com/matlab.zip">If you don't have matlab click here.</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA['Tweaks' and 'Leaps' in Collaborative Innovation: Ned Gulley and Karim Lakhani]]></title>
<link>http://fringethoughts.wordpress.com/?p=124</link>
<pubDate>Tue, 24 Jun 2008 19:12:10 +0000</pubDate>
<dc:creator>aaron</dc:creator>
<guid>http://fringethoughts.wordpress.com/?p=124</guid>
<description><![CDATA[Ned Gulley (Mathworks) and Karim Lakhani (Harvard Business School) presented some forthcoming work o]]></description>
<content:encoded><![CDATA[<p>Ned Gulley (Mathworks) and Karim Lakhani (Harvard Business School) presented some forthcoming work on Collaborative Innovation today at Harvard's <a title="Berkman Center for Internet and Society" href="http://cyber.law.harvard.edu" target="_self">Berkman Center</a><a title="Berkman" href="http://cyber.law.harvard.edu" target="_self"> for Internet and Society</a>.</p>
<p>The paper builds on Ned's work at <a title="Mathowrks" href="http://www.mathworks.com/" target="_self">Mathworks</a> developing collaborative programming competitions for the <a title="Matlab" href="http://en.wikipedia.org/wiki/Matlab" target="_self">MATLAB </a>community. Adopting "the perspective of the code" it analyzes what happens when you set a horde of geeks loose on a fun, challenging programming problem in a networked collaborative environment.</p>
<p>To sum up my reactions really briefly, I thought the paper was an exciting step in the process of looking under the hood of collaborative knowledge production. Gulley and Lakhani argue that as programmers improved the performance of code relative to a discreet problem, they did so through "tweaks" and "leaps."</p>
<p>"Tweaks" represent small refinements that improve the performance of existing code; "Leaps" represent more sudden and large-scale advances in performance (usually driven by introducing a more substantive or extensive change in the code).</p>
<p>Tweakers and Leapers benefit from each other's work, but the biggest beneficiary of their combined interactions was the code itself. Within one week of the competitions, thousands of eyeballs had produced startling solutions to complex algorithmic problems.</p>
<p>There's a lot more to be learned from this kind of work - especially from the sort of experimental data created in the setting of these sort of large-scale collaborative games. In particular, I'm interested in thinking about how programmers (whether as individuals or communities) adapted to the challenges over time. It seems like it might be possible to design a game that could test whether efficient collaborative problem solving techniques "evolved" over the course of the game(s). In addition, it would be fascinating to test the results of this kind of collaboration against those produced by more hierarchical or individuated models of innovative work.</p>
<p>Look for links to the soon-to-be-published version of the paper on the "publications" section of <a title="Karim R. Lakhani" href="http://drfd.hbs.edu/fit/public/facultyInfo.do?facInfo=ovr&#38;facEmId=klakhani@hbs.edu" target="_self">Karim's HBS faculty page</a>.</p>
<p>In the meantime, I'm told that video and audio of today's presentation should be available on the Berkman Center's <a title="Berkman Center for Internet and Society" href="http://cyber.law.harvard.edu/interactive" target="_self">"interactive section"</a> by tomorrow afternoon at the latest.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Cutting glass with knapsacks]]></title>
<link>http://abcdefu.wordpress.com/?p=139</link>
<pubDate>Fri, 20 Jun 2008 09:04:27 +0000</pubDate>
<dc:creator>abi</dc:creator>
<guid>http://abcdefu.wordpress.com/?p=139</guid>
<description><![CDATA[Suppose you are a thief and you stealthily enter a house carrying only a backpack. The residents ast]]></description>
<content:encoded><![CDATA[<p>Suppose you are a thief and you stealthily enter a house carrying only a backpack. The residents astonishingly only have five objects in the house (as shown below). How do you maximize your profits so that everything you take fits in your backpack? If you can answer this question, then you have solved the knapsack problem. Like many problems, the knapsack problem is easy enough to state but tough to solve. For sufficiently large scenarios, no optimum solution can be found.</p>
<p style="text-align:center;"><a href="http://abcdefu.wordpress.com/files/2008/06/picture-53.png"><img class="alignnone size-medium wp-image-141 aligncenter" src="http://abcdefu.wordpress.com/files/2008/06/picture-53.png?w=243" alt="" width="243" height="212" /></a></p>
<p><!--more--></p>
<p>I have written <a href="http://www.mediafire.com/?xxnnzqrd2wu">some code</a> in MATLAB that can find optimal solutions for the rectangular knapsack problem where you have to maximise the area used when fitting smaller rectangles into the larger tile. For example, in the diagram below, how do you fit the 2x3 and 3x4 rectangles into the 5x5 tile such that you use the most area in the 5x5 tile? Rectangular knapsack needs to be solved very often in many industries including the glass cutting industry where you want to complete your orders but don’t want to waste glass (in other words, maximise area used).<br />
<a href="http://abcdefu.files.wordpress.com/2008/06/picture-52.png"></a><br />
I used straightforward dynamic programming in the solution which means that I try to find the optimal solutions of the subproblems and then, combine the subproblems to find the optimal solution of the main problem. So, using the set of given rectangles, I optimise area used in 1x1 tile and then using those results, I optimise a 1x2 tile and so on, until I find the optimal solution for the 5x5 tile. Using such a method, we can solve pretty large problem instances in a reasonable amount of time.</p>
<p style="text-align:center;"><img class="alignnone size-medium wp-image-140 aligncenter" src="http://abcdefu.wordpress.com/files/2008/06/picture-52.png?w=300" alt="" width="358" height="197" /></p>
<p>Based on a lot of research, there are many interesting ways in which we can make the code even faster. One of the optimizations that I am using is discretization points <span style="font-size:11px;">[1] </span>which preserves the optimality of the solution. These points are the only points where you can cut the tile and so, obviously, you need to only consider these points. With respect to the earlier example, we actually don't need to consider the 1x1 tile sub-problem because it is never possible to have any rectangles in such a small tile. So, using this optimisation, we only need to consider a tiles with dimensions like 2x3 or 2x4.</p>
<p>Besides the rectangular knapsack (found in rk.m), I also consider the same problem allowing for rotation and allowing for staged cutting. All the code can be found <a href="http://www.mediafire.com/?xxnnzqrd2wu">here</a> and the instructions to use the functions can be found in readme.rtf.</p>
<p><span style="font-size:11px;">[1] Based on ideas in <em>Algorithms for two-dimensional cutting stock and strip packing problems using dynamic programming and column generation by G.F. Cintra, F.K. Miyazawa, Y. Wakabayashi, E.C. Xavier<br />
</em></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Finding the length of curve using MATLAB]]></title>
<link>http://autarkaw.wordpress.com/?p=26</link>
<pubDate>Wed, 18 Jun 2008 00:43:49 +0000</pubDate>
<dc:creator>Autar Kaw</dc:creator>
<guid>http://autarkaw.wordpress.com/?p=26</guid>
<description><![CDATA[As per integral calculus, the length of a continuous and differentiable curve f(x) from x=a to x=b i]]></description>
<content:encoded><![CDATA[<p>As per integral calculus, the <a href="http://www.mathwords.com/a/arc_length_of_a_curve.htm">length of a continuous and differentiable curve f(x) from x=a to x=b</a> is given by</p>
<p>S=$latex \int_a^b \sqrt{(1+(dy/dx)^2} dx $</p>
<p>Now how do we find the length of a curve in MATLAB.</p>
<p>Let us do this via an example.  Assume one asked you to find the length of $latex x^2*sin(x) $ from Π to 2Π.  In the book, <a href="http://www.nap.edu/html/howpeople1/">How People Learn</a>, the authors mention that learning a concept in multiple contexts prolongs retention.  Although it may not be the context that the authors of the book are talking about, let us find the length of the curve multiple ways within MATLAB.  Try the program for functions and limits of your own choice to evaluate the difference.</p>
<p><strong>METHOD 1</strong>: Use the formula S=$latex \int_a^b \sqrt{(1+(dy/dx)^2} dx $ by using the diff and int function of MATLAB</p>
<p><strong>METHOD 2</strong>: Generate several points between a and b, and join straight lines between consecutive data points.  Add the length of these straight lines to find the length of the curve.</p>
<p><strong>METHOD 3</strong>. Find the derivative dy/dx numerically using forward divided difference scheme, and then use trapezoidal rule (trapz command in MATLAB) for discrete data with unequal segments to find the length of the curve.</p>
<p><strong>QUESTIONS TO BE ANSWERED: </strong></p>
<ol>
<li>Why does METHOD 3 giving inaccurate results?  Can you make them better by using better approximations of derivative like central divided difference scheme?</li>
<li>Redo the problem with f(x)=$latex x^{\frac{3}{2}}   $ with a=1 and b=4 as the exact length can be found for such a function.</li>
</ol>
<p>% Simulation : Find length of a given Curve<br />
% Language : Matlab 2007a<br />
% Authors : Autar Kaw<br />
% Last Revised : June 14 2008<br />
% Abstract: We are finding the length of the curve by three different ways<br />
% 1. Using the formula from calculus<br />
% 2. Breaking the curve into bunch of small straight lines<br />
% 3. Finding dy/dx of the formula numerically to use discrete function<br />
% integration<br />
clc<br />
clear all</p>
<p>disp('We are finding the length of the curve by three different ways')<br />
disp('1. Using the formula from calculus')<br />
disp('2. Breaking the curve into bunch of small straight lines')<br />
disp('3. Finding dy/dx of the formula numerically to use discrete function integration')</p>
<p><span style="color:#ff0000;">%INPUTS - this is where you will change input data if you are doing<br />
% a different problem<br />
syms x;<br />
% Define the function<br />
curve=x^2*sin(x)<br />
% lower limit<br />
a=pi<br />
% b=upper limit<br />
b=2*pi<br />
% n = number of straight lines used to approximate f(x) for METHOD 2<br />
n=100<br />
%p = number of discrete data points where dy/dx is calculated for METHOD 3<br />
p=100</span></p>
<p>% OUTPUTS<br />
% METHOD 1. Using the calculus formula<br />
% S=int(sqrt(1+dy/dx^2),a,b)<br />
% finding dy/dx<br />
poly_dif=diff(curve,x,1);<br />
% applying the formula<br />
integrand=sqrt(1+poly_dif^2);<br />
leng_exact=double(int(integrand,x,a,b));<br />
fprintf ('\nExact length =%g',leng_exact)<br />
%***********************************************************************</p>
<p>% METHOD 2. Breaking the curve as if it is made of small length<br />
% straight lines<br />
% Generating n x-points from a to b</p>
<p>xi= a:(b-a)/n:b;<br />
% generating the y-values of the function<br />
yi=subs(curve,x,xi);<br />
% assuming that between consecutive data points, the<br />
% curve can be approximated by linear splines.<br />
leng_straight=0;<br />
m=length(xi);<br />
% there are m-1 splines for m points<br />
for i=1:1:m-1<br />
dx=xi(i+1)-xi(i);<br />
dy= yi(i+1)-yi(i);<br />
leneach=sqrt(dx^2+dy^2);<br />
leng_straight=leng_straight+leneach;<br />
end<br />
fprintf ('\n\nBreaking the line into short lengths =%g',leng_straight)</p>
<p>% METHOD 3. Same as METHOD1, but calculating dy/dx<br />
% numerically and integrating using trapz<br />
xi=a:(b-a)/p:b;<br />
% generating the dy/dx-values<br />
m=length(xi);<br />
for i=1:1:m-1<br />
numer=yi(i+1)-yi(i);<br />
den=xi(i+1)-xi(i);<br />
dydxv(i)=numer/den;<br />
end<br />
% derivative at last point using Backward divided difference formula<br />
% is same as Forward divided difference formula<br />
dydxv(m)=dydxv(m-1);<br />
integrandi=sqrt(1+dydxv.*dydxv);<br />
length_fdd=trapz(xi,integrandi);<br />
disp(' ')<br />
disp(' ')<br />
disp ('Using numerical value of dy/dx coupled')<br />
disp ('with discrete integration')<br />
fprintf (' =%g',length_fdd)</p>
<p><span style="color:#800000;">This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at <a href="http://numericalmethods.eng.usf.edu/">http://numericalmethods.eng.usf.edu</a></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Smooth surface fitting to a 3D point cloud]]></title>
<link>http://irych.wordpress.com/?p=7</link>
<pubDate>Tue, 17 Jun 2008 12:25:14 +0000</pubDate>
<dc:creator>rychphd</dc:creator>
<guid>http://irych.wordpress.com/?p=7</guid>
<description><![CDATA[Say we have a 3D point cloud (from a LIDAR or Terrestrial Laser Scanning) and wish to fit a smooth s]]></description>
<content:encoded><![CDATA[<p>Say we have a 3D point cloud (from a <a href="http://en.wikipedia.org/wiki/LIDAR">LIDAR</a> or Terrestrial Laser Scanning) and wish to fit a smooth surface to it. Why? Because it being smooth should remove the outliers and spikes, and fill in the nodata holes with. Well, we're already talking about the holes in the 2D raster grid that we have previously sorted our point cloud to. Why 2D grid? In the geography sciences they like DEMs - raster grids with <strong>z</strong>-elevations per each cell, usually mapped to a color. Having sorted the points one can take the average <strong>z</strong> per cell, and have a DEM right away. It's if the number of points per cell is enough for talking about <strong>zmean </strong>and other statistics. With the smooth surface fitting we want to recover the finer details, by interpolating-extrapolating-approximating, that is replacing the point cloud with points over regularly spaced fine grid. By going to the fine scale like this, it would make more sense to keep the 3D features: like points under and above rocks and gravel. But a <strong>z=f(x,y)</strong> should only have one value per <strong>dx,dy</strong> cell. John's gridfit takes <strong>zmean </strong>for such duplicate points. Going to the 3D surface model, for example using Radial Basis Functions RBF, which implies finding a signed distance 3D function and taking 0-isosurface, ...may look like an overkill, if only we could work with multi-z functions defined over 2D support.</p>
<p>Anyway, the current plan is as follows:</p>
<p>Find the 2D smooth surface<br />
Find the 3D smooth surface</p>
<p>Compare the results to see how much is the difference in voids matter for the calculation of <a href="http://en.wikipedia.org/wiki/Porous">porosity</a></p>
<p>Available sources: gridfit in Matlab, Surface generation packages in <a href="http://grass.osgeo.org/wiki/LIDAR#Surface_generation">LIDAR GRASS</a>. FastRBF is no longer in development and is not open source. However, is downloadable and provides promising results.</p>
<p><a href="http://www-graphics.stanford.edu/papers/surfacefitting/surf_fit.pdf">Fitting Smooth Surfaces to Dense Polygon Meshes.pdf</a></p>
<p><a href="http://vis.cs.brown.edu/docs/pdf/Grimm-2002-FMS.pdf">Fitting Manifold Surfaces To 3D Point Clouds.pdf</a>: "In general, parametric curve and surface fitting to irregular data can be formulated as a non-linear least squares problem..."</p>
<p><a title="Spline (mathematics)" href="http://en.wikipedia.org/wiki/Spline_%28mathematics%29">spline</a> surfaces and curves, where <a class="mw-redirect" title="Bézier splines" href="http://en.wikipedia.org/wiki/B%C3%A9zier_splines">Bézier splines</a> are required to interpolate certain control points, while <a title="B-spline" href="http://en.wikipedia.org/wiki/B-spline">B-splines</a> are not.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[A simple MATLAB program to show that High order interpolation is a bad idea]]></title>
<link>http://autarkaw.wordpress.com/?p=24</link>
<pubDate>Mon, 16 Jun 2008 18:07:20 +0000</pubDate>
<dc:creator>Autar Kaw</dc:creator>
<guid>http://autarkaw.wordpress.com/?p=24</guid>
<description><![CDATA[In a previous post, we talked about that higher order interpolation is a bad idea.

In this post I a]]></description>
<content:encoded><![CDATA[<p>In a <a href="http://autarkaw.wordpress.com/2008/06/14/higher-order-interpolation-is-a-bad-idea/">previous post</a>, we talked about that higher order interpolation is a bad idea.</p>
<p><img style="border:2px solid black;vertical-align:top;margin:2px;" src="http://numericalmethods.eng.usf.edu/blog/runge3.bmp" alt="Runge's function " /></p>
<p>In this post I am showing you a MATLAB program that will allow you to experiment by changing the number of data points you choose, that is, the value of n (see the input highlighted in red in the code - this is the only line you want to change) and see for yourself why high order interpolation is a bad idea.  Just, cut and paste the code below (or download it from <a href="http://www.eng.usf.edu/~kaw/download/runge.m">http://www.eng.usf.edu/~kaw/download/runge.m</a>) in the MATLAB editor and run it.</p>
<h3>% Simulation : Higher Order Interpolation is a Bad Idea</h3>
<p>% Language   : Matlab r12<br />
% Authors    : Autar Kaw<br />
% Last Revised : June 10 2008<br />
% Abstract: In 1901, Carl Runge published his work on dangers of high order<br />
%                 interpolation. He took a simple looking function f(x)=1/(1+25x^2) on<br />
%                 the interval [-1,1].  He took points equidistantly spaced in [-1,1]<br />
%                 and interpolated the points with polynomials.  He found that as he<br />
%                 took more points, the polynomials and the original curve differed<br />
%                even more considerably.  Try n=5 and n=25<br />
clc<br />
clear all<br />
clf</p>
<p>disp('In 1901, Carl Runge published his work on dangers of high order')<br />
disp('interpolation. He took a simple looking function f(x)=1/(1+25x^2) on')<br />
disp('the interval [-1,1].  He took points equidistantly spaced in [-1,1]')<br />
disp('and interpolated the points with a polynomial.  He found that as he')<br />
disp('took more points, the polynomials and the original curve differed')<br />
disp('even more considerably.  Try n=5 and n=15')</p>
<p>%<br />
% INPUT:<br />
% Enter the following<br />
% n= number of equidisant x points from -1 to +1<br />
<span style="color:#ff0000;">n=15;</span></p>
<p>% SOLUTION<br />
disp(' ')<br />
disp('SOLUTION')<br />
disp('Check out the plots to appreciate: High order interpolation is a bad idea')<br />
fprintf('\nNumber of data points used =%g',n)<br />
% h = equidisant spacing between points<br />
h=2.0/(n-1);<br />
syms xx<br />
% generating n data points equally spaced along the x-axis<br />
% First data point<br />
x(1)=-1;<br />
y(1)=subs(1/(1+25*xx^2),xx,-1);<br />
% Other data points<br />
for i=2:1:n<br />
x(i)=x(i-1)+h;<br />
y(i)=subs(1/(1+25*xx^2),xx,x(i));<br />
end</p>
<p>% Generating the (n-1)th order polynomial from the n data points<br />
p=polyfit(x,y,n-1);</p>
<p>% Generating the points on the polynomial for plotting<br />
xpoly=-1:0.01:1;<br />
ypoly=polyval(p,xpoly);</p>
<p>% Generating the points on the function itself for plotting<br />
xfun=-1:0.01:1;<br />
yfun=subs(1/(1+25*xx^2),xx,xfun);</p>
<p>% The classic plot<br />
% Plotting the points<br />
plot(x,y,'o','MarkerSize',10)<br />
hold on<br />
% Plotting the polynomial curve<br />
plot(xpoly,ypoly,'LineWidth',3,'Color','Blue')<br />
hold on<br />
% Plotting the origianl function<br />
plot(xfun,yfun,'LineWidth',3,'Color','Red')<br />
hold off<br />
xlabel('x')<br />
ylabel('y')<br />
title('Runges Phenomena Revisited')<br />
legend('Data points','Polynomial Interpolant','Original Function')<br />
%***********************************************************************<br />
disp('  ')<br />
disp('  ')<br />
disp('What you will find is that the polynomials diverge for')<br />
disp('0.726&#60;&#124;x&#124;&#60;1.  If you started to choose same number of points ')<br />
disp('but more of them close to -1 and +1, you would avoid such divergence.  ')<br />
disp('  ')<br />
disp('However, there is no general rule to pick points for a general ')<br />
disp('function so that this divergence is avoided; but some rules do exist for ')<br />
disp('certian types of functions.')</p>
<p><span style="color:#800000;">This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at <a href="http://numericalmethods.eng.usf.edu/">http://numericalmethods.eng.usf.edu</a></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Matlab and Ubuntu]]></title>
<link>http://raulmonsalve.wordpress.com/?p=40</link>
<pubDate>Thu, 12 Jun 2008 06:50:35 +0000</pubDate>
<dc:creator>raulmonsalve</dc:creator>
<guid>http://raulmonsalve.wordpress.com/?p=40</guid>
<description><![CDATA[After some time of research, here is how it worked for me:
Install normally following the documentat]]></description>
<content:encoded><![CDATA[<p>After some time of research, here is how it worked for me:</p>
<p>Install normally following the documentation, even if it doesn't ask for symbolic links. Then go to the installation directory (/usr/local/matlab in my case):</p>
<p>./install_matlab -glnx</p>
<p>Answer 'y' to all questions and keep the suggestions (this takes care of the license stuff).  In the same directory as the matlab file (e.g. /usr/local/matlab/bin/) create a file (I called it matlab2 -- you can call it matlab2.sh). In this file write</p>
<p>export AWT_TOOLKIT=3DMToolkit<br />
/usr/local/matlab/bin/matlab</p>
<p>Now in the terminal type (still within /usr/local/matlab/bin/)</p>
<p>chmod 755 matlab2</p>
<p>Finally, start Matlab by doing</p>
<p>./matlab2</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Master MATLAB]]></title>
<link>http://diasap.wordpress.com/?p=49</link>
<pubDate>Wed, 11 Jun 2008 13:04:13 +0000</pubDate>
<dc:creator>dias0407</dc:creator>
<guid>http://diasap.wordpress.com/?p=49</guid>
<description><![CDATA[Want to be a master in MATLAB ????
read this ebook&#8230; Master Matlab.zip

]]></description>
<content:encoded><![CDATA[<p>Want to be a master in MATLAB ????<br />
read this ebook... <a href="http://www.ziddu.com/download.php?uid=Z7KflZ2sa7OiluKnY6qhkZSrYKuZl5qq3">Master Matlab.zip<br />
</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Iterative Methods for Optimization: Matlab Codes]]></title>
<link>http://thailatex.wordpress.com/2008/06/11/iterative-methods-for-optimization-matlab-codes/</link>
<pubDate>Wed, 11 Jun 2008 05:45:30 +0000</pubDate>
<dc:creator>tsvhh</dc:creator>
<guid>http://thailatex.wordpress.com/2008/06/11/iterative-methods-for-optimization-matlab-codes/</guid>
<description><![CDATA[&nbsp;
Iterative Methods for Optimization: Matlab Codes 
จดไว้ใช้ยามยาก
]]></description>
<content:encoded><![CDATA[<p>&#160;</p>
<p><a href="http://www4.ncsu.edu/~ctk/matlab_darts.html">Iterative Methods for Optimization: Matlab Codes</a> </p>
<p>จดไว้ใช้ยามยาก</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Numerical Differentiation with MATLAB]]></title>
<link>http://thailatex.wordpress.com/2008/06/09/numerical-differentiation-matlab/</link>
<pubDate>Mon, 09 Jun 2008 22:08:58 +0000</pubDate>
<dc:creator>tsvhh</dc:creator>
<guid>http://thailatex.wordpress.com/2008/06/09/numerical-differentiation-matlab/</guid>
<description><![CDATA[ช่วงนี้กำลังกลุ้มใจมาก เพราะต้องหา]]></description>
<content:encoded><![CDATA[<p>ช่วงนี้กำลังกลุ้มใจมาก เพราะต้องหา Jacobian ของ Spline ปัญหาคือมันไม่สามารถหาเชิง<br>วิเคราะห์ได้ จำเป็นต้องหาเชิงเลขบน MATLAB เพราะต้องการหาจุดตรึงของ Spline ที่เหมาะ<br>สมที่สุด </p>
<p>ทางเลือกหนึ่งคือใช้ฟังก์ชัน <a href="http://www.mathworks.com/access/helpdesk/help/toolbox/splines/index.html?/access/helpdesk/help/toolbox/splines/fndir.html&#38;http://www.mathworks.com/cgi-bin/texis/webinator/search/?db=MSS&#38;prox=page&#38;rorder=750&#38;rprox=750&#38;rdfreq=500&#38;rwfreq=500&#38;rlead=250&#38;sufs=0&#38;order=r&#38;is_summary_on=1&#38;ResultCount=10&#38;query=jacobian+spline&#38;submitButtonName=Search">fndir</a> ซึ่งมากับ Spline Toolbox อันนี้ไม่ค่อยอยากใช้นักเพราะว่า<br>เครื่องที่บ้านไม่มี Toolbox อันนี้ (เวอร์ชันนักเรียน) ต้องไปใช้ที่ห้องทำงาน อีกทางเลือกหนึ่ง<br>ดูเป็นเรื่องทั่วไปกว่า โดยการใช้ <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=13490#">Automatic Numerical Differentiation</a> ของคุณ <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&#38;objectId=801347">John</a><br>&#160;<a href="http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&#38;objectId=801347">D'Errico</a> ซึ่งยังไม่รู้ว่าดีแค่ไหน </p>
<p>ตัวผมเองไม่ได้สนใจศึกษาเรื่อง Numerical Computing เลย จนหลัง ๆ อ่านมากชักจะชอบ<br>ไปเจอบทเรียน <a href="http://www.maths.lth.se/na/courses/FMN081/">Numerical Methods in Mechanics</a> ของ <a href="http://www.lth.se/">Lund University</a> ก็ขอจดไว้<br>หน่อย รหัสต้นข้างล่างนี้ลอกมาแปะไว้เลย ตัวฟังก์ชันชื่อ jacobian ก็ควรจะเปลี่ยนนะครับเพราะ<br>ไปซ้ำกับ jacobian แบบ symbolic ของ MATLAB เค้า</p>
<blockquote><p>function [J]=jacobian(func,x)<br>% computes the Jacobian of a function<br>n=length(x);<br>fx=feval(func,x);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; %บรรทัดนี้คือการคำนวณค่าฟังก์ชันที่ x<br>eps=1.e-8; % could be made better<br>xperturb=x;<br>for i=1:n<br>&#160;&#160; xperturb(i)=xperturb(i)+eps;<br>&#160;&#160; J(:,i)=(feval(func,xperturb)-fx)/eps;&#160;&#160;&#160;&#160; %อันนี้คือการหาค่าอนุพันธ์<br>&#160;&#160; xperturb(i)=x(i);<br>end;</p>
<p>&#160;</p>
</blockquote>
<p>น่าสนุกดีเหมือนกัน </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Optical flow in matlab]]></title>
<link>http://chi3x10.wordpress.com/?p=42</link>
<pubDate>Mon, 09 Jun 2008 19:26:22 +0000</pubDate>
<dc:creator>chi3x10</dc:creator>
<guid>http://chi3x10.wordpress.com/?p=42</guid>
<description><![CDATA[Implementation based on Horn&#8217;s optical flow algorithm. 


function [Vx,Vy] = OpticalFlow(image]]></description>
<content:encoded><![CDATA[<p>Implementation based on Horn's optical flow algorithm. </p>
<p>[sourcecode language='cpp']</p>
<p>function [Vx,Vy] = OpticalFlow(images,alpha,iterations)<br />
%// Calculating optical flow of a sequence of images.<br />
%// images : 3D array that contains a sequence of images. size of images is (imageHeight, imageWidth, frame number)<br />
%// alpha<br />
%// iterations.<br />
[height,width,frames]=size(images);</p>
<p>%//initialzation of u and v<br />
Vx = zeros(height,width);<br />
Vy = zeros(height,width);</p>
<p>for k = 1:frames-1</p>
<p>    % //initialization of Ex Ey and Et<br />
    Ex = zeros(height-1,width-1,frames-1);<br />
    Ey = zeros(height-1,width-1,frames-1);<br />
    Et = zeros(height-1,width-1,frames-1);</p>
<p>    %//calculating Ex Ey and Et in frame k.<br />
    for x = 2:width-1<br />
        for y = 2:height-1<br />
            Ex(y,x,k) = (images(y+1,x+1,k)-images(y+1,x,k)+images(y,x+1,k)...<br />
                -images(y,x,k)+images(y+1,x+1,k+1)-images(y+1,x,k+1)...<br />
                +images(y,x+1,k+1)-images(y,x,k+1))/4;</p>
<p>            Ey(y,x,k) = (images(y,x,k)-images(y+1,x,k)+images(y,x+1,k)...<br />
                -images(y+1,x+1,k)+images(y,x,k+1)-images(y+1,x,k+1)...<br />
                +images(y,x+1,k+1)-images(y+1,x+1,k+1))/4;</p>
<p>            Et(y,x,k) = (images(y+1,x,k+1)-images(y+1,x,k)+images(y,x,k+1)...<br />
                -images(y,x,k)+images(y+1,x+1,k+1)-images(y+1,x+1,k)...<br />
                +images(y,x+1,k+1)-images(y,x+1,k))/4;<br />
        end<br />
    end</p>
<p>    for nn = 1:iterations<br />
        for x = 2:width-1<br />
            for y = 2:height-1</p>
<p>                Vxbar = (Vx(y-1,x)+Vx(y,x+1)+Vx(y+1,x)+Vx(y,x-1))/6+...<br />
                     (Vx(y-1,x-1)+Vx(y-1,x+1)+Vx(y+1,x+1)+Vx(y+1,x-1))/12;</p>
<p>                Vybar = (Vy(y-1,x)+Vy(y,x+1)+Vy(y+1,x)+Vy(y,x-1))/6+...<br />
                    (Vy(y-1,x-1)+Vy(y-1,x+1)+Vy(y+1,x+1)+Vy(y+1,x-1))/12;</p>
<p>                %// chapter 12 of Horn's paper<br />
                temp = (Ex(y,x,k)*Vxbar+Ey(y,x,k)*Vybar+Et(y,x,k))/(alpha^2 + Ex(y,x,k)^2 + Ey(y,x,k)^2);<br />
                %// update u and v<br />
                Vx(y,x) = Vxbar-Ex(y,x,k)*temp;<br />
                Vy(y,x) = Vybar-Ey(y,x,k)*temp;<br />
            end<br />
        end<br />
    end</p>
<p>end</p>
<p>[/sourcecode]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Graphiques sur surface complexe avec Matlab]]></title>
<link>http://fcontino.wordpress.com/?p=11</link>
<pubDate>Wed, 04 Jun 2008 12:44:12 +0000</pubDate>
<dc:creator>fcontino</dc:creator>
<guid>http://fcontino.wordpress.com/?p=11</guid>
<description><![CDATA[Lorsqu&#8217;on veut faire un plot (en 2d ou 3d) sur une surface particulière, on peut utiliser la ]]></description>
<content:encoded><![CDATA[<p>Lorsqu'on veut faire un plot (en 2d ou 3d) sur une surface particulière, on peut utiliser la fonction patch de Matlab.</p>
<p><code>patch(x,y,c)</code></p>
<p>d'autres options peuvent être ajoutées (voir doc).</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Postprocessing matlab des simulations fluent]]></title>
<link>http://fcontino.wordpress.com/?p=10</link>
<pubDate>Wed, 04 Jun 2008 08:01:13 +0000</pubDate>
<dc:creator>fcontino</dc:creator>
<guid>http://fcontino.wordpress.com/?p=10</guid>
<description><![CDATA[Utiliser la fonction export de fluent pour écrire un fichier texte contenant toutes les infos dont ]]></description>
<content:encoded><![CDATA[<p>Utiliser la fonction export de fluent pour écrire un fichier texte contenant toutes les infos dont on veut le postprocessing:<br />
<code>file/export ascii <em>fileName</em> () no <em>scalarToExport</em> q no yes</code></p>
<p><em>fileName</em> est le fichier vers lequel on veut exporter les champs <em>scalarToExport</em> (ex: <em>temperature</em>)</p>
<p>Ensuite sous Matlab, on va construire les vecteurs qui permettront la visualisation:<br />
<!--more--><br />
<code>file = fopen('fileName');<br />
fgetl(file); %passer la première ligne qui reprend les intitulés<br />
readed = fscanf(file,'%g',[<em>nbScalars+3</em> inf]); %stocke les scalaires ainsi que les                                                  %infos de maillages<br />
x = readed(2,:);<br />
y = readed(3,:);<br />
scalars = readed(4:end,:);</p>
<p>detail = 1000; % à changer si on veut plus de détails<br />
[X,Y] = meshgrid(min(x):(max(x)-min(x))/detail:max(x),min(y):(max(y)-min(y))/detail:max(y)); %création des matrices X et Y pour la fonction pcolor<br />
Z = griddata(x,y,z,X,Y);<br />
ax = axes;<br />
pcolor(X,Y,Z);<br />
set(ax,'CLim',[300 900]); %limites pour le champ ploté<br />
shading interp; %effet sur le rendu<br />
lighting phong; %effet sur l'éclairage<br />
axis image; %la figure conserve la proportion pour la représentation de la figure<br />
colorbar; %affiche une colorbar;</p>
<p>print('-dpng','-r100',filename); %export la figure en png résolution 100<br />
clf reset; %annule la figure<br />
</code></p>
<p> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Построение графиков функций и объемных геометрических фигур в octave]]></title>
<link>http://aleosblog.wordpress.com/?p=20</link>
<pubDate>Wed, 07 May 2008 17:05:23 +0000</pubDate>
<dc:creator>aleos</dc:creator>
<guid>http://aleosblog.wordpress.com/?p=20</guid>
<description><![CDATA[Продолжаю серию заметок с примерами работы в octave. Наде]]></description>
<content:encoded><![CDATA[<p>Продолжаю серию заметок с примерами работы в octave. Надеюсь, это окажется кому-то полезным.</p>
<pre>
set (0, 'defaulttextfontname', 'Terminus,16');

%% Maclaurin's trisectrix
figure(1)

phi = -3*pi/2 : .2 : 3*pi/2;
alpha = pi;
r = alpha ./ cos(phi/3);
<!--more-->

subplot(1,2,1)
plot(phi,r,'-r')
title('rectangular coordinates')
axis([-2*pi 2*pi 0 10*pi])
xlabel('\phi')
ylabel('r')
grid on

subplot(1,2,2)
polar(phi,r,'-b')
title('polar coordinates')
axis([-5*pi 5*pi -5*pi 5*pi])
xlabel('\phi')
ylabel('r')
grid on

%% nonlinear equations

figure(2)

% 3x^5 - 8x^3 - 18x^2 + 2 = 0
subplot(3,1,1)
x = -3:0.1:3;
y = 3*x.^5 - 8*x.^3 - 18*x.^2 + 2;
plot(x,y,"-r;3x^5 - 8x^3 - 18x^2 + 2 = 0;")
axis([-3 3 -3 3])

Y = [3 0 -8 -18 0 2]
roots(Y)

hold on
plot(roots(Y), '*b')
hold off

grid on

% 5^x = 2 + e^{-2x}
subplot(3,1,2)
x = -8:0.01:10;
y = 5.^x - 2 - exp(-2*x);
plot(x,y,"-b;5^x = 2 + e^{-2x};")
axis([-4 5 -10 10])
grid on

% x^3+y^3=8 y=1+x^{3/2}
subplot(3,1,3)
x = -5:0.001:5;
y1 = (8-x.^3).^(1/3);
y2 = 1+x.^(3/2);
plot(x,y1,"-b;x^3+y^3=8;", x, y2, "-r;y=1+x^{3/2};")
axis([-2 5 0 10])
grid on

%% elliptic paraboloid

% \frac{y^2}p + \frac{z^2}q = 2x
figure

a=4;
b=20;
u = (0:0.05:5)';
v = [0:0.05*pi:2*pi];
X = a*sqrt(u)*cos(v);
Y = b*sqrt(u)*sin(v);
Z = u*ones(size(v));
surf(X,Y,Z);

shading interp
colormap pink
</pre>
]]></content:encoded>
</item>

</channel>
</rss>
