how to send a variable in a for loop through serial communication

1 view (last 30 days)
To the monochromator controller i need to give the step count values in an increment order via a serial port. The commands are monochromator control are '-1000', '-1012', '1024', '-1036'..... '-1144' and so on.. Instead of using
fprintf (s1, '-1000');
fprintf (s1, '-1012');
fprintf (s1, '-1024');
fprintf (s1, '-1036')
...
...
...
fprintf (s1, '-1144')
I want to use a 'for loop' for the same above mentioned operation. Can you please help me in this regard. Thanks in advance.

Answers (1)

Walter Roberson
Walter Roberson on 21 Jan 2014
for K = 1000 : 12 : 1144
fprintf(s1, '-%d\n', K);
end

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!