2017/09/30

Matlab: Plot multiple curves with legend

Example 1: Draw sin(x), sin(x/2) and sin(x)+sin(x/2)

>> x = 0:360;
>> y1 = sind(x);
>> y2 = sind(x/2);
>> y3 = y1+y2;
>> plot(x, y1, x, y2, x, y3);
>> legend('sin(x)','sin(x/2)','sin(x)+sin(x/2)')

Result:



Example 2: Draw log(x), log2(x), log10(x)

>> x = 0:0.01:5;
>> y1 = log(x);
>> y2 = log2(x);
>> y3 = log10(x);
>> plot(x, y1, x, y2, x, y3)
>> legend('log(x)','log2(x)','log10(x)')

Result:


Example 3: 3e-0.25*tsin(5t)

>> t = 0:0.01:30;
>> x1 = 3*exp(-0.25*t).*sin(5*t);
>> x2 = 0.2*cos(2*t);
>> x3 = 3*exp(-0.25*t).*sin(5*t)+0.2*cos(2*t);
>> plot(t,x1,t,x2,t,x3);
>> legend('x1','x2','x3');

Result:



Related Information:

Draw an Exponential Function with exp() with a custom Y-axis at x = 0
Exponential Function & Natural Logarithm 指數函數與自然對數

2017/09/28

Matlab: Hello GUI with guide

To draw a window or the graphical user interface (GUI) with Matlab, type:

>> guide

Select Blank GUI (Default):


A window for GUI design is displayed:



Draw something such as a "Hello World!" static text and some buttons.


Save the design figure as your preferred name, e.g. gui_layout.fig



A corresponding m file such as gui_layout.m is automatically created.


In the Command Window, type the name of the m-file e.g. type gui_layout and the window designed previously is displayed.








2017/09/02

OSI Model 開放式系統互聯通訊參考模型

OSI - Open System Interconnection
Open System Interconnection reference model 開放式系統互聯通訊參考模型 (Wikipedia/維基百科)

Layer 7 - Application 應用層

Layer 6 - Presentation 表達層/展示層

Layer 5 - Session 會議層/交談層

Layer 4 - Transport 傳輸層
Example: TCP (Transmission Control Protocol). Connection-oriented links for conveying segments of data.
Example: UDP (User Datagram Protocol). Connectionless transmission model. For Multimedia traffic.

Layer 3 - Network 網路層 Example: IP (Internet Protocol). Data transported as packets.

Layer 2 - Data Link 資料鏈結層
Logical Link Control (LLC) sublayer
Media Access Control (MAC) sublayer - e.g. CSMA/CD (802.3), CSMA/CA (802.11)

Layer 1 - Physical 實體層

References:

Communication Systems (4th Edition) by Simon Haykin, Wiley 2001, p11-12.
What is the difference between TCP and IP protocols?
Transmission Control Protocol(Wikipedia)
User Datagram Protocol(Wikipedia)
OSI七層簡介