【发布时间】:2014-03-22 17:45:14
【问题描述】:
我正在做这个项目,我的目标是在图表上绘制每秒 BPM 并逐点更改图表的颜色。
我有一个包含数据的 CSV 文件,此时我可以绘制 BPM 与时间图。但是,我的下一个目标是为不同区域更改此图表的颜色。
我已将 CSV 文件中的 LED 颜色定义为 a-red、b-green、c-yellow 和 d-blue。样本数据如下:
秒 BPM LED
1 64 a
2 140 c
3 162 d
4 110 b
5 112 b
6 145 c
7 146 c
8 149 c
9 145 c
10 60 a
这是我目前拥有的绘制 BPM 与时间关系图的代码。现在我必须根据 CSV 文件中的 LED 字母更改颜色。
ftoread = 'DATALOG.CSV';
fid = fopen(ftoread); %OPENS the CSV file
data = textscan(fid,'%f%f%f%c','Headerlines',1,'Delimiter',',');
fclose(fid); % closes the file
Time = data{1}; %Time variables moved to new variable called x
BPM = data{2};% Readings moved to variable y
LED= data{3};
plot(Time,BPM, 'r'); % plot bp readings vs time
xlabel('Time of Reading');
ylabel('Blood Pressure Reading & Speed');
title('Blood Pressure Readings vs Time');
【问题讨论】:
-
查看Scatter。 (示例做你想要的,只需将 a,b,c,d 所做的更改为值)