mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-02-28 11:54:30 +03:00
restructuring
This commit is contained in:
13
F0:F030,F042,F072/Socket_fans/knots/buildk.m
Normal file
13
F0:F030,F042,F072/Socket_fans/knots/buildk.m
Normal file
@@ -0,0 +1,13 @@
|
||||
function [X0 Y0 K] = buildk(X, Y, dYmax)
|
||||
%
|
||||
% [X0 Y0 K] = buildk(X, Y, dYmax) - build arrays of knots (X0, Y0) and linear koefficients K
|
||||
% for piecewise-linear approximation of Y(X) with max deviation `dYmax`
|
||||
%
|
||||
X0 = []; Y0 = []; K = [];
|
||||
knots = [1 getknots(X, Y, dYmax) max(size(X))];
|
||||
for i = 1:max(size(knots))-1
|
||||
idx = knots(i):knots(i+1);
|
||||
[x y k] = linearapprox(X(idx), Y(idx));
|
||||
X0 = [X0 x]; Y0 = [Y0 y]; K = [K k];
|
||||
endfor
|
||||
endfunction
|
||||
Reference in New Issue
Block a user