MATLAB: Tuning parameters using signal constraint blockset wtih an AC signal as the reference

optimizationparameterssimulinkSimulink Response Optimization

I feed it a 60hz reference variable from teh workspace and it just pops out the parameter values that I already have. Plus the signal that is generated doesn't look anything like the reference that I am asking it to tune it's response to.
The question is can I use an AC signal for the reference? If so how do I use it? Thank you, Daniel

Best Answer

Hi Daniel,
I don't know your exact problem but generally trying to match frequency characteristics from time domain signals is tricky.
For example consider a simple frequency estimation problem, where we try to use a sum-squared-error value to optimize a sinusoid frequency to match a reference:
w0 = 2*pi*60; %Reference frequency
w = linspace(0.5*w0,2*w0,1e3); %Frequency to tune/identify
T = 0.2; %Time horizon
%Compute analytic SSE(w) = \int_0^T | sin(w_0 t) - sin(w t) |^2 dt
SSE = T - 0.5 * sin(2*w0*T)/(2*w0) - 0.5*sin(2*w*T)./(2*w)...
- sin( (w-w0)*T )./(w-w0) + sin( (w+w0)*T )./(w+w0);
%Plot SSE
plot(w,SSE)
title('SSE(w)=\int_0^T | sin(w_0 t) - sin(w t) |^2 dt')
xlabel('w')
Notice that the SSE has multiple local minima. I believe this is similar to what you are observing, that is the optimizer is getting stuck in a local minima. For the simple problem above I tried using a Signal constraint block with simplex algorithm instead of gradient descent and achieved reasonable results.
If possible an alternative is to formulate the problem directly in terms of frequency. Could you calculate the frequency of the signal that you want to tune and pass that to the Signal Constraint block and have it track the reference 60hz constant value?
Hope that helps
-Alec