2018/04/18

Signal-to-Noise Ratio (SNR)

Signal-to-Noise Ratio (SNR) 訊號雜訊比/訊雜比/訊噪比/信噪比

SNR = (signal power)/(noise power) = Psignal/Pnoise
SNRdB = 10log10(SNR) = 10log10(Psignal)-10log10(Pnoise) in decibels (dB)

Therefore, if Psignal > Pnoise,

SNR > 1 and SNRdB > 0 dB.

If SNRdB < 0, Psignal < Pnoise. In other words, when the SNRdB is negative, the power of the signal is weaker than the power of background noise.

Reference

Signal-to-noise ratio/訊號雜訊比 (Wikipedia)

2018/04/14

Matlab: Laplace Transform

The examples below demonstrate the Laplace transforms and inverse Laplace transforms using Matlab symbolic number or variable.

Laplace Transform

L{1} = 1/s

>> x = sym(1);
>> laplace(x)

ans =

1/s

L{t} = 1/s2

>> syms t
>> laplace(t)

ans =

1/s^2

Inverse Laplace Transform

L-1{1/s} = 1

>> syms s
>> ilaplace(1/s)

ans =

1

L-1{1/(s-a)} = eat where a = 2

>> ilaplace(1/(s-2))

ans =

exp(2*t)

L-1{a2/(s2+a2)} = sin(at) where a = 1

>> ilaplace(1/(s^2+1))

ans =

sin(t)

Reference

Zill, D., Wright, W. S., & Cullen, M. R. (2011). Advanced engineering mathematics. 4th Edition. Jones & Bartlett Learning. p 197-198.

laplace / ilaplace - MathWorks Documentation

2018/04/12

Matlab: Basic Differentiation and Integration with the syms symbolic variable

To perform basic calculus calculations with Matlab, declare symbolic variables with syms command:

>> syms x;
>> y = 3*x^3+2*x^2-4*x+5;

Hence y = 3x3+2x2-4x+5.

For differentiation, the derivative of y is y' = diff(y):

>> y_prime = diff(y)

y_prime =

9*x^2 + 4*x - 4

Hence y' = dy/dx = 9x2+4x-4.

For integration, the integral of y is ∫ y dy = int(y):

>> y_integral = int(y)

y_integral =

(3*x^4)/4 + (2*x^3)/3 - 2*x^2 + 5*x

Consequently, ∫ y dy = (3x4)/4 + (2x3)/3 - 2x2 + 5x + c.

2018/04/10

Matlab: Simple structure with dot (.)

To create a basic form of structure in Matlab, simply use a dot (.) as below:

>> mystruct.name = "peter";
>> mystruct.age = 15;
>> mystruct.hobby = "swimming";
>> mystruct

mystruct =

  struct with fields:

     name: "peter"
      age: 15
    hobby: "swimming"