필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Shailendra
Shailendra 2014년 1월 21일
답변: Walter Roberson 2014년 1월 21일
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.

답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by