MATLAB: Implementing temperature varying parameters in simulink and MATLAB

dc motorMATLABparameterssimulinktemperature

Hello,
I'm currently trying to model a DC Motor in MATLAB 2015a with temperature varying parameters. The parameters here are the resistance of the armature (R_a) and the motor constant (K_m). The goal is to implement a model which accurately represents the variation of these parameters with temperature during the operation of the motor (an initial reference model if you will, something which would accurately reflect the measured values). The end goal is to develop a parameter estimator which will correctly predict the variation of the above mentioned parameters.
Ideally I would like the temperature to vary with the simulation time in Simulink, so that I could then write a few if-else condition statements in a MATLAB script which would then select the correct motor parameters to reflect the temperature change.
How do I implement a "Temperature signal" in Simulink which changes with the simulation time?
Thanks in advance,
Vijay

Best Answer

OK. I understand better your problem. A MATLAB S-Function can be used to do this. Attached is an example in which the MATLAB Sfunction uses 3 different techniques for adjusting the Gain parameter in a gain block at different times during the 10 sec simulation. First uses set_param to change param directly. Second and third change workspace variable used by Gain block.