📄 read.m
字号:
function [out,success]=read(filename,old,retries);
%
% function to wait for the next reading to become available
%
% [out]=read(filename,old,retries)
%
% out = returned process vector
% old = previous index of process vector
% filename = name of the transfer file
% success = 1 for OK read
% success = -1 for timeout
% retries = number of attempts to get the data
%
out=[];
success=-1;
%
% Wait until file becomes available
%
cd d:
for i = 1:retries
%
% Wait for 0.25 secs
%
tic;
while toc < 0.1
drawnow;
end
fid=fopen('transfer.dat','r');
drawnow;
%
% Pause for a tad
%
if fid ~= -1
fclose(fid);
tic;
while toc < 0.1
drawnow;
end
load transfer.dat
if sum(transfer) ~= sum(old)
out=transfer;
success=1;
break;
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -