(一)
% 你可以根据实际的分隔符进行设置
opts = delimitedTextImportOptions('Delimiter', ',');
% 读入(.txt)文档,文档以分隔符进行分离 -> table
data = readtable('D:\QT_Project\servo\recvData.txt', opts);
% table -> cell
dataMatrix = table2array(data);
% cell -> double
sendData_cell = dataMatrix(:, 2);
sendData = str2num(char(sendData_cell));
recvData_cell = dataMatrix(:, 3);
recvData = str2num(char(recvData_cell));
interval_cell = dataMatrix(:, 14);
interval1 = str2num(char(interval_cell));
interval_value = interval1(1);
% 生成自然数序列
x = (1:length(sendData)) * (interval_value/1000);
% 绘制sendData曲线
plot(x, sendData, 'r');
hold on;
% 绘制recvData曲线
plot(x, recvData, 'b');
% 添加图例
legend('sendServo', 'recvServo');
title('舵机1');