Obtain input knowing output and transfer function
45 views (last 30 days)
David Wilson on 7 Jun 2019
Since you have a simple transfer function, here's what I would do.
(1) First generate some data that we will subsequently try to "invert" back to the time domain. Make sure the input is not sharp like a step.
%% Calculate input from thermo ID
G = tf(1,[14,1]);
Ts = 0.1; % appropriate sample time
t = [0:Ts:50]'; % time vector
U = sin(t) + 0.6*sin(t*0.35-4); % trial (smoothish) input
Now do the simulation. This is a reconstruction of the data you have started with.
y = lsim(G,U,t);
Now we are ready to reconstruct the input u(t), so we need to invert your process transfer function. HOWEVER I've added some fast dynamics to make the inverse system causal. We need to do this, but it will now be approximate. The fast dyanmics should be faster than the original dynamics (tau=14) in your case.
%% Now back-calculate u(t)
fast = 0.1;
Ginv = (1/G)*tf(1,[fast^2 2*fast 1])
ur = lsim(Ginv,y,t)
plot(t,[U, ur]) % compare