The Use of Matlab TIMER to Send Text

2
[matlab] April 15, 2012 [email protected] Page 1 THE USE OF MATLAB TIMER TO SEND TEXT Okay, this is not so important article actually. The idea behind this text is the possibility to use TIMER Matlab Function to help on shceduling. I choose sending text scheduling as case to solve. This program might be able to be extended into other great applications. We dont need any complex instruction here and no need to learn kind of math algorithm.. To make it simple, lets move on to first case where I consider to make a clock displayed on matlab window. Here is the codes: function myclock() % make timer with periode 1 second wkt = timer('period',1.0); set(wkt,'ExecutionMode','fixedrate','StartDelay',0.5); set(wkt,'timerfcn',['clc;',... 'tk=datestr(clock,''mmm.dd,yyyy HH:MM:SS'');',... 'disp(''Current Time'');',... 'disp(tk)']); start(wkt); when executed, it displays formatted current time: And for the sending text codes, here it is function mydatatimer() wkt = timer('period',10); set(wkt,'ExecutionMode','fixedrate','StartDelay',0.5); set(wkt,'timerfcn',['fID = fopen(''coba.txt'',''a+'');',... 'fprintf(fID,''texting to you'');',... 'fclose(fID);',... 'disp(''texting to you'');']); start(wkt);

Transcript of The Use of Matlab TIMER to Send Text

Page 1: The Use of Matlab TIMER to Send Text

[matlab] April 15, 2012

[email protected] Page 1

THE USE OF MATLAB TIMER TO SEND TEXT

Okay, this is not so important article actually. The idea behind this text is the possibility to use

TIMER Matlab Function to help on shceduling. I choose sending text scheduling as case to solve.

This program might be able to be extended into other great applications. We dont need any

complex instruction here and no need to learn kind of math algorithm.. ☺

To make it simple, lets move on to first case where I consider to make a clock displayed on

matlab window.

Here is the codes:

function myclock()

% make timer with periode 1 second wkt = timer('period',1.0); set(wkt,'ExecutionMode','fixedrate','StartDelay',0.5); set(wkt,'timerfcn',['clc;',... 'tk=datestr(clock,''mmm.dd,yyyy HH:MM:SS'');',... 'disp(''Current Time'');',... 'disp(tk)']);

start(wkt);

when executed, it displays formatted current time:

And for the sending text codes, here it is

function mydatatimer()

wkt = timer('period',10); set(wkt,'ExecutionMode','fixedrate','StartDelay',0.5); set(wkt,'timerfcn',['fID = fopen(''coba.txt'',''a+'');',... 'fprintf(fID,''texting to you'');',... 'fclose(fID);',... 'disp(''texting to you'');']);

start(wkt);

Page 2: The Use of Matlab TIMER to Send Text

[matlab] April 15, 2012

[email protected] Page 2

well, actually i have tried some smart way to make the codes. I mean by creating a function that

contains important codes or codes that will be run by the timer function. But when i tried to call

this function from timer function, it did not work. So I use this stupid way to make it works...

funny you Matlab... ☺

By the way, here is the result when last program executed.

Okay, we can use other application instead of notepad such as Excel as long as matlab has its

support. I hope you guys can do better than this, and make extend application based on above

programs.

@ thanks