我正在尝试使用 Matlab 读取 CSV 文件并绘制它。基本上,我想绘制时间与心率的关系。但是,当我使用textscan
它将两列复制到一个中时,我不确定如何将其分开。我想将时间保存在变量中x
,将心率保存在变量中y
并绘制它们。
到目前为止,我已经这样做了:
clear, clc;
ftoread = 'data.csv';
fid = fopen(ftoread); %Reads the CSV file
data = textscan(fid,'%s%f'); % Read in a string and a double
fclose(fid); % close
for i=2:size(data{1,1},1)% checks for size of the csv file
x = strnum(data);%i need to separate the time from BPM using the comma thing and string command
%y = data{2};
end
plot(x,y);
在 Matlab 的data
单元格中,这就是我所看到的:
'Time,BPM(HeartRate)'
'5:55:26,0'
'5:55:26,66'
'5:55:27,69'
'5:55:27,71'
'5:55:27,72'
等等
在for
循环中,我想将时间分开并将其保存在一个变量中,并将心率设置为另一个变量。