Info
此问题已关闭。 请重新打开它进行编辑或回答。
Adaptive Minimization for loop
2 次查看(过去 30 天)
显示 更早的评论
I have a DAC that I'm calibrating by measuring the values. I use a simple search to find the minimum between a voltage I desire and the measured voltage of the DAC. (don't worry, I know how to calibrate DAC's with a polynomial but I can't do that in this case.) Instead of using a stepped search where I change the values I would like to use an adaptive approach to make the algorithm faster.
I am using hardware in the loop. How can I use an adaptive algorithm to make the minimization faster?
findvalue = 0.5;%desired voltage
flagreached = 1;%flag if done finding voltage
count = 1;
while flagreached
voltage(count) = voltagefromADC();%Measure voltage
if count > 6 %wait 6 measurements before averaging
meanv = mean(voltage(count-5:count));
if meanv< findvalue - 0.5
compdacV = compdacV + 100;
elseif meanv< findvalue - 0.05
compdacV = compdacV + 10;
elseif meanv< findvalue -0.005
compdacV = compdacV + 1;
elseif meanv <= findvalue
%found value
flagreached = 0;
end
end
changeDAC(compdacV);%Set the DAC
compdacVvec(count) = compdacV;
count = count +1;
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!