int
int16_t
16-bit signed integeruint32_t
32 bit unsigned integerfloat32_t
32 bit (single precision) floating pointExample: measuring clock cycles
uint32_t* systick = (uint32_t*) 0xe000e018;
void tic(void)
{
t = *systick;
}
uint32_t toc(void)
{
return t - *systick;
}
int16_t table[16];
float32_t amplitude;
flat32_t omega0 = 0.0576;
for (uint32_t n = 0; n < 16; n+=1)
{
amplitude = arm_sin_f32(n * omega0);
table[n] = OUTPUT_SCALE_FACTOR * amplitude;
}
Example: Shift all elements of an $N=16$ element array and add a new element to the start.
float32_t x[16] = {0};
int32_t position = 0;
.
.
.
void circular_buffer_shift(float32_t new_element)
{
position = (position-1) % 16
x[position] = new_element
}
single()
, int16()
, uint32()
, etc)whos()
functioni
and j
represent $\sqrt{(-1)}$. Be careful naming variables that overwrite these!j
is added, e.g. 1-3j
A = [1,2,3
4,5,6];
B = [7,8,9
3,2,1];
Element-wise product of two matrices using for loops
for i_row = 1:2
for i_col = 1:3
C(i_row,i_col) = A(i_row,i_col) * B(i_row,i_col);
end
end
A = [1,2,3
4,5,6];
B = [7,8,9
3,2,1];
element-wise product of two matrices using .*
operator
C = A .* B;
Matrix-matrix product using *
operator and '
for transpose.
C = A * B';
plot()
function the (x,y) coordinates of each point you want to plotplot(x,y)
to represent continuous signalsstem(x,y)
to represent discrete signalsfigure()
function before a plot to put it in a new windowhold on;
to overlay on the previous plotset(0,'DefaultFigureWindowStyle','Docked')
to keep all figures in the same window but make an new tab for each
Preview of the different transforms we will use in this class:
All of these have certain properties in common (with a few caveats)
What is the fourier transform of $ x(t) = \left(1+\cos(2\pi t)\right) \left( \text{rect}(t) \right)$ ?
The Fourier transform of a constant $1$ is $\delta(f)$.
The Fourier transform of $ \cos(at) $ is $\frac{1}{2}\left[ \delta(f-\frac{a}{2\pi}) + \delta(f+\frac{a}{2\pi}) \right]$
The Fourier transform of $ \text{rect} (t) $ is $\text{sinc}(f)=\frac{\sin(\pi f)}{\pi f}$
Multiplication in time domain is convolution in frequency domain
Sifting property: $f(t) * \delta(t-t_0) = f(t-t_0)$