MATLAB Examples

Read CPU Temperature on Simulink® Real-Time™

This example shows how to read CPU temperature in degrees Celsius (°C).

Requirements:

  1. Boot the target computer with the Simulink Real-Time real-time kernel.
  2. At the MATLAB® command prompt, type dslrtCPUTemperatureDemo to download and run the model on the target computer.

Contents

Select and Open the Model

mdl='dslrtCPUTemperature';
open_system(fullfile(matlabroot,'toolbox','rtw','targets','xpc','xpcdemos',mdl));

Build, Download, and Run the Model

slrtpingtarget;
set_param(mdl,'RTWVerbose','off');
rtwbuild(mdl);
tg = slrt;
tg.load(mdl);
tg.start;
pause(20);
tg.stop;
### Starting Simulink Real-Time build procedure for model: dslrtCPUTemperature
### Generated code for 'dslrtCPUTemperature' is up to date because no structural, parameter or code replacement library changes were found.
### Successful completion of build procedure for model: dslrtCPUTemperature
### Created MLDATX ..\dslrtCPUTemperature.mldatx
### Looking for target: TargetPC1
### Download model onto target: TargetPC1

Close the Model

close_system(mdl,0);