What is the most efficient code for calculating a signal based on voltage time history and a calibration curve.
古いコメントを表示
% Lets assume that you have a voltage signal v = v(t) from a measurement (120 seconds at 500 hz sample rate)
t = 0:0.002:120;
v = randn(size(t));
% The calibration curve for the data is a curve that CANNOT be describe with a polynomial function.
vc = linspace(-2,2,15); % voltage
yc = [-9.9353 -8.2974 -5.7543 -3.5560 -2.0043 -1.2284 -0.5819 0.3233 2.0043 4.8491 6.9612 8.5991 9.4181 9.6336 9.8060]; % physical unit
% The trivial solution to calculate y is
tstart = tic;
for i=1:length(t)
y(i) = interp1(vc,yc,v(i),'cubic');
end
telapsed = toc(tstart);
The question is: What is the most efficient way to implement the calculation of y?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!