This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <type_traits> | |
#include <string> | |
#include <variant> | |
#include <vector> | |
#include <memory> | |
using variant_t = std::variant<int, double, std::string>; | |
struct AbstractDispatcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [thd, p0, l0] = thdf( P1, f, varargin ) | |
%thdf Computes the total harmonic distortion to the fundamental. | |
% Fundamental is the first harmonic peak that's larger than 2% than | |
% the largest harmonic in the supplied frequency spectrum. | |
% | |
% thd = thdf( P1, f ) | |
% | |
% P1 Single-sided amplitude spectrum of the signal. | |
% f Frequency span of P1. | |
% thd Total harmonic distortion. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ y, r, c ] = spwm( f1, fc, varargin ) | |
%SPWM Generates sine-wave modulated bipolar PWM. | |
% Will produce the closest possible to a single period of f1. | |
% [ y, t, c ] = spwm( f1, fc, varargin ) | |
% | |
% f1 Base harmonic frequency. | |
% fc Carrier frequency. | |
% 'NSamples' [100] Samples per 1/fc period. | |
% 'Method' ['left'] 'left', 'right' or 'center'. | |
% 'ModIndex' [1] Modulation index. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ P1, f ] = ssfft( X, Fs ) | |
%ssfft Computes the single-sided amplitude spectrum of a signal. | |
% https://www.mathworks.com/help/matlab/ref/fft.html | |
% [ P1, f ] = ssfft( X, Fs ) | |
% | |
% X Input signal. | |
% Fs Sampling frequency. | |
% P1 Single-sided Amplitude Spectrum. | |
% f Frequency range. | |
% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int sgn(int x) { | |
return (x >= 0 ? 1 : -1); | |
} | |
int main(int argc, char * argv[]) { | |
if(argc != 3) { | |
printf("ERROR: Supply X and Y target position!\n"); |