Saturday, February 15, 2014

Group Velocity / Phase Velocity Animation - Case 2: Zero Group Velocity


In this second video of the series, we demonstrate the case where the group velocity is zero while the phase velocity is positive number. The individual wave components comprising the total wave are first shown at the top along with a corresponding "dot" representing the phase velocity of each component.

In the bottom figure, we have the resulting wave that travels along the +x direction with a positive phase velocity but the group velocity remains to be zero. The wave packet envelope is shown in magenta color in dashed lines.

For the other videos in the series, check the below links:
1) Group Velocity larger than Phase Velocity: https://www.youtube.com/watch?v=tlM9vq-bepA


Групповая скорость, Gruppengeschwindigkeit, Voortplantingssnelheid, Velocidad de grupo, Grupa rapido, Vitesse de groupe, Velocità di gruppo, 군속도, מהירות חבורה, ჯგუფური სიჩქარე, 群速度, Gruppefart, Prędkość grupowa, Групова швидкість, 群速度, Vận tốc nhóm, Grupphastighet, Grupinis greitis, Phasengeschwindigkeit, Velocidad de fase, 相速度, Vitesse d'une onde, Velocità di fase, Фазовая скорость, 位相速度

Sunday, February 02, 2014

Fast Fourier Transform (FFT) Animation using Matlab



We show the progress of Fast Fourier Transform (FFT) of a time-domain signal as it changes in time. Matlab's fft() function is used for illustration, hence it should be noted that the function is assumed to be periodic. The number of FFT point is assumed to be same as the time domain signal to prevent zero padding when the full domain is filled. In the beginning a sinusoidal signal at 50 Hertz (1*sin(2pi*50*t)) starts to develop and slowly fills the full domain. Then, another sinusoidal signal at a higher amplitude and 100 Hertz (1.5*sin(2pi*100*t)) is added to this signal. Later, a third sinusoidal signal at 200 Hz replaces the 100 Hz one. Following this, a DC component (0 Hz) is inserted and finally, the DC component is removed. At each stage, the the development of frequency components can clearly be observed. In the frequency spectrum, first a 50Hz component starts to build up along with lower and higher frequencies. The reason for wider spectrum is the fact that sinusoidal signal fills the domain within an increasing time window (hence introduction of sinc components). Once the full domain is filled with the sinusoidal, then only 50 Hz component remains due to the fact that the signal assumes to be periodic in Matlab fft function.

Wednesday, January 01, 2014

How to change the default background color for Matlab figure?

One of the signatures of Matlab is the grayish background color it uses for its figures unless it is changed intentionally. In conference presentations or posters, one can easily detect Matlab outputs thanks to this color. For those who want to change this color right from the startup can do so by editing the default settings of Matlab. To access the default settings, type get(0,'Default') in the Matlab command line. Then, it will display all the default settings. This is how my settings are:

get(0,'Default')

ans = 

          defaultFigurePosition: [680 678 560 420]
               defaultTextColor: [0 0 0]
              defaultAxesXColor: [0 0 0]
              defaultAxesYColor: [0 0 0]
              defaultAxesZColor: [0 0 0]
          defaultPatchFaceColor: [0 0 0]
          defaultPatchEdgeColor: [0 0 0]
               defaultLineColor: [0 0 0]
    defaultFigureInvertHardcopy: 'on'
             defaultFigureColor: [0.8000 0.8000 0.8000]
               defaultAxesColor: [1 1 1]
          defaultAxesColorOrder: [7x3 double]
          defaultFigureColormap: [64x3 double]
        defaultSurfaceEdgeColor: [0 0 0]

For our particular target of changing the default figure background, one can simply change the defaultFigureColor attribute to any desired color, e.g. to white, as follows:
set(0,'defaultFigureColor',[1 1 1])
Similarly, to black as follows:

set(0,'defaultFigureColor',[0 0 0])
And here is how the outputs look when any figure is opened after the change in the default setting.

With default background color
Modified background color: White

Modified background color: Black

Tuesday, December 24, 2013

PEPEÇURA - Kara Üzüm Muhallebisi


Pepeçura'nın en son hali
Bugüne kadar internet sayesinde farklı şehirlerde (taşınmaktan dolayı) geride bıraktığım bir çok çocukluk arkadaşıma ulaşabilmiş ve her birinde de farklı heyecanlar yaşamıştım. Geçenlerde çocukluk arkadaşlarını bulmanın heyecanını arattırmayan bir başka olay daha yaşadım. Bu olayın kahramanı ise Karadeniz bölgesi dışında çok da bilinmeyen kara üzümden yapılan Pepeçura muhallebisiydi. İnternette gezerken şans eseri  karşıma çıkınca bir anda çocukluk yıllarıma geri döndürdü beni. Çocukken neredeyse her yaz Çengelköy'e Anneannemlere giderdik, hem o hem de etrafdaki diğer Laz akrabaların etkisiyle sanki "Little Arhavi"ye gitmiş gibi olurduk. Etrafımızda bu kadar çok Laz'ın olması sayesinde Laz mutfağından farklı yiyecekleri tadma imkanimiz olurdu (Bunlardan en önemlilerinden olan Kapça Mçkudi yani Hamsili Pilavı burada daha önce anlatmıştım). İşte Pepeçura'yı da arada sırada Anneannem bizler için yapardı. Kendine özgü bordo rengi ile ister istemez Trabzonspor'u (ve doğal uzantısı olarak hamsiyi) hatırlatan bu muhallebinin önce kokusu sonra da tadı insanı kendisine bağlardı. Tabi o zaman çocukluktan ötürü, bu nedir, nasıl yapılır gibi sorularla ilgilenmez, sadece tüketmeye odaklanırdık. Zamanla Anneannem de yapmaz olunca, etrafta baska yapan da olmayinca, yavaş yavaş unuttuk gitti bu muhallebiyi. Ta ki tekrar resmini internette görene kadar. Sanki eski bir çocukluk arkadaşımı daha bulmuş gibi sevindim. Ama ufak bir sorun vardı, sadece resmini görmek yetmiyor, bir kere daha tadına bakmak gerekiyordu. Eşime, çocuklarıma, arkadaşlarıma bakın böyle bir muhteşem bir tad var demek istiyordum.


Madem Anneannemden binlerce kilometre uzaktaydım, bu muhallebiyi kendim yapmak dışında bir seçeneğim yoktu. Eşimin de yardımıyla internette kısa bir araştırma sonucu çeşitli tariflerine ulaştık. Okuduğumuz tarifleri burada elimizdeki malzemelere göre ayarlayıp yapmaya başladık. Sonuç olarak bence (en azından aklımda kaldığı kadarıyla) hem tad hem de görüntü olarak çok iyi bir sonuç çıkardık. Hem kendi arşivim, hem çocuklarım hem de meraklıları için bizim deneyip iyi sonuç verdiğini düşündüğümüz tarifi burada paylaşmak istiyorum. 
Muhallebinin adı Lazca'da Pepeçura olarak geçiyor. Bazı sitelerde kara üzüm hatta Karadeniz üzümü muhallebisi olarak da geçiyor. İsminden de anlaşılacağı gibi malzeme olarak öncelikle kokulu kara üzüm gerekiyor. Türkiye piyasasında Karadeniz üzümü olarak satılıp satılmadığından emin değilim. Burada ise marketlerde sıkça bulunan kırmızı California ya da Şili üzümleri en iyi seçenekler. Biz  bu sefer için 3 poundluk (yaklaşık 1.5 kilo)  paketlerde satılan California üzümü kullandık. Üzümleri yıkadıktan sonra bir bardak su ile birlikte kaynatmak gerekiyor. İlk kaynamada üzümler üstteki resimde görüldüğü gibi suya renklerini veriyorlar. Daha sonra bu kaynamış üzümleri blender veya mikserden geçirmek lazım. Üzümlerin çekirdeksiz olması bu aşamada önemli. Blender sonrası oluşan karışım yandaki resimdeki gibi görünüyor. Oluşan karışımı ayrıca süzgeçten geçirip posası azaltılabilir. Ama bence posanın kalması hem miktarı artırma açısından hem üzümdeki fiberleri koruma açısından hem de gereksiz israf olmaması açısından daha iyi olacaktır. Bundan sonraki aşama karışımı mısır unu ile karıştırmak. Burada Meksika ürünlerini satan reyonlarda mısır unu bulmak mümkün. Bizde daha önceden alınmış mısır nişastası olduğu için onu kullandık. Yaklaşık 3 yemek kaşığı nişastayı aşağıdaki resimlerdeki gibi koyup karıştırdıktan sonra kaynamasını bekliyoruz. Zaten bu karıştırma işlemi bildiğiniz gibi muhallebi ve çorba gibi yemekler için olmazsa olmaz şartlardan. Kaynama başlar başlamaz ateşten kaldırıp servis kaselerine koyup soğumalarını beklememiz gerekiyor. İsteğe bağlı olarak üzerine hindistan cevizi ve üzüm taneleri koyulabilir. Bir başka sefere sarı üzüm ve burada çok bulunan böğürtlen ve benzeri meyveler (raspberry, blackberry vs) ile de yapmayı planlıyorum. 

Kullandığımız mısır nişastası
Tabaklara servis aşaması
Soğumaya bırakıldıktan hemen sonra


Kaynaklar:

Monday, December 23, 2013

How to rectify imagesc() axis in Matlab?

In Matlab, imagesc() and pcolor() are among the most used 2D plotting commands. For a given 2D matri, when you use the imagesc() command the y-axis comes inverted with respect to pcolor() command. To fix this issue and bring the y-axis increasing in positive y direction (with respect to screen plane), simply using axis xy is sufficient. Here is a small code snippet:


%% Difference between pcolor and imagesc
A=[ 1  2  3  4 7;
    5  6  7  8 -1; 
    9 10 11 12 3;
    2 3 4  6 7;
    9 10 11 12 3;
    1 2 7 -1 10;
    ];

figure (1); clf; set(gcf,'Color',[1 1 1]);
subplot(1,3,1);
pcolor(A); colorbar;
title('{\bf pcolor}(A)'); axis image;

subplot(1,3,2);
imagesc(A); colorbar;
title('{\bf imagesc}(A)'); axis image;

subplot(1,3,3);
imagesc(A); colorbar;
title('{\bf imagesc}(A) with {\bf axis xy}'); axis image;
axis xy
 


- For an earlier post on the difference of imagesc() and pcolor(), check here.
- Another post discusses the inclusion of grid lines to imagesc() here.

Friday, December 06, 2013

Night Train to Turkistan - Google Map of the Stuart Stevens and his company's trip along the Ancient Silk Road

Although the title is enticing, the book itself is not a great book. It focuses more on how the hotels they stayed were, the bus and train details and almost nothing about the culture and history of places they have passed. If you are reading to learn about the Turkistan and its people, this is not the book to do so. It is more about the daily practicality of their journey, how they found the bus/train where they sat and how it was etc. The author is obsessed to follow the route of Fleming without any particular reason and they cannot achieve that. Anyways, one of the nice part of the book is the map it has provided. I transferred it to Google Maps to see how the landscape they pass is and here is the link to that: (Opening the map in full screen mode is recommended)
e

Displaying grid lines in imagesc() function in Matlab


The default plot of pcolor() command in Matlab is to display the grid lines separating the each cell (top right figure below). One can use shading flat to remove the grid lines. However, for the imagesc() command, the default is not to show the grid lines (top left figure below). Below is  simple code snippet showing how to force imagesc() to have grid lines.

nx=4;
ny=4;
A=randn(nx,ny);

figure (8); clf; set(gcf,'Color',[1 1 1]);
subplot(2,2,1); 
imagesc(A); title('plain {\bf imagesc()}'); 
pbaspect([nx ny 1]);

subplot(2,2,2); 
pcolor(A);  title('plain {\bf pcolor()}')
pbaspect([nx ny 1]);

% With grid lines plotted
subplot(2,2,3:4); 
imagesc(A);
pbaspect([nx ny 1]);
title('{\bf imagesc()} with grid lines separating each cell')
set(gca,'xtick', linspace(0.5,nx+0.5,nx+1), 'ytick', linspace(0.5,ny+.5,ny+1));
set(gca,'xgrid', 'on', 'ygrid', 'on', 'gridlinestyle', '-', 'xcolor', 'k', 'ycolor', 'k');
- For an earlier post on the difference between pcolor() and imagesc(), click here.
- Note, syntax highligthing achieved by http://tohtml.com/matlab/

Thursday, December 05, 2013

Diffraction from a wedge - TMz case [FDTD simulation]


Here, we demonstrate the diffraction from a wedge when a plane wave with electric field component normal to the surface is impinging on it. The wedge corner acts as a secondary source to generate cylindrically propagating waves which are clearly seen when the scattered field plots on the right is analyzed. The left side of the animation shows the total field where both the scattered and incident fields are plotted together.





Beugung, Difracción, Diffrazione, Kırınım, 回折, Дифракция, Diffractie, Difração, 衍射, Dyfrakcja, Diffraktion, Interferenz, Interferencia

Saturday, September 28, 2013

How to Generate Animation Video using Matlab?

Let's say you have a mathematical function changing in time (or in any other quantity) and you would like to watch it progress and create an animation out of it. That is very simple to integrate into an existing Matlab code. Basically, by using the mov and getframe(), addframe() commands, one can easily generate the animation file. Below is a sample code snippet for further reference:


mov = avifile('test.avi','fps',7,'quality',100,'keyframe',1);
     
     
    figure('Renderer','zbuffer')
    Z = peaks;
    surf(Z);
    axis tight
    set(gca,'NextPlot','replaceChildren');
    % Preallocate the struct array for the struct returned by getframe
    F(20) = struct('cdata',[],'colormap',[]);
    % Record the movie
    for j = 1:200
        surf(.01+sin(2*pi*j/20)*Z,Z)
        F(j) = getframe;
     
        F = getframe(gcf);
        mov = addframe(mov,F);
     
        pause(0.1);
    end
     
    mov = close(mov); 





Note: I used the following website to obtain the highlighted Matlab code in html: http://tohtml.com/matlab/

Monday, September 02, 2013

Hacı Münib Engin Noyan'ın Hatıratından bir Anı


Hacı Münib Engin Noyan'ın hayatını anlattığı Fatma Güzey'in sunduğu televizyon programında bahsettiği çarpıcı bir anısı var ki, yazıya dökülmesi belki daha çok kişinin duymasına, öğrenmesine vesile olacağı için burada transkriptini çıkarmaya çalıştım. Yorumsuzca aktarıyorum:



...
[Noyan] Bir aile dostumuz - Allah taksiratını affetsin - Prof. Dr. Max Neineke (?) ben daha 16 yaşlarında iken falan bana bir sual sormuştu. Demişti ki "Berlin'de ne oynuyor tiyatroda?".... Biliyorum... "Londra'da ne oynuyor?"... Biliyorum. Çünkü gazetelerden [biliyorum]. "Peki" dedi, "Atina da ne oynuyor?" dedi [Bilmiyorum anlamına gelen yüz ifadesi]

[Güzey] Yunanistanla çok bir şeyiniz yok... bağlantınız...

[Noyan] "Şam'da ne oynuyor? [yine cevap yok]. Bağdad'da ne oynuyor? E sen kendi coğrafyanı tanımıyorsun. Onları [batıyı] tanıyorsun. Biri burnunun dibi. Şam'da tiyatro var mı yok mu onu bile bilmiyorsun. Böyle bir şey olur mu?" dedi bana.

[Güzey] E yönümüz tamamen Avrupa'ya döndürülmüş, altta ne var yanda ne var bilmiyoruz

[Noyan] Ve şu muazzam cümleyi kullandı. Dedi ki "Siz, Türkler" dedi, "Çok aptalsınız".... Sinirlendim tabi. Niye aptal diyorsun ki bana yani? Niye? dedim. "Çünkü" dedi. "Siz doğudan gelen trenin lokomotifi olmak yerine, batıya giden trenin son vagonu olmayı tercih ettiniz." dedi.

[Güzey] Çok güzel bir cümle..

[Noyan] Muazzam bir cümle.. ...
Doğudan gelen medeniyet treninin lokomotifi olmak varken, ki bizim hala da konumumuz o,  elhamdulillah - batıya giden trenin son vagonu olduk. En arkada hayvanları koydukları, uyduruk... Sallana sallana gidip serseme dönmüş

[Güzey] Her an kopma tehlikesi ile de karşı karşıya olan

[Noyan] Evet, birinci sınıf vagon bile olamadık. En son vagon...


.......



Programın tamamının linki (yukarıdaki kısım için 27:00'dan itibaren dinleyebilirsiniz):
http://youtu.be/H8CiJ9XD0sQ

Engin Noyan'ın resmi web sitesi:
http://enginnoyan.com.tr/