如何解决在 for 循环中绘制数据
我在使用 for
循环绘制数据时遇到问题。就目前而言,我的函数如下所示:
function fig = Function1(input1,input2,input3)
fig = figure('Visable',false);
%% Load in all files from 3 different folders (input1,input3)
%% Initiate for loop and process data on each file iteration. After data is processed,plot results from that iteration and hold on to the plot for the next iteration.
for i = 1 : length(Text_Files1)
% Read in data as tables
% Process data (Cropping data ect)
% Pass through function to calculate heart rates
[~,HR,~] = HrFunction(data1,...
data2);
% Calculate average heart rate over segments. (xTime is a datetime array)
hrT = seconds(xTime - startTime);
TrendWindow = 900;
TimeSegment = 1:TrendWindow:max(hrT);
% Iterate through each time segment and calculate average heart rate
for x = 1:length(TimeSegment)-1
SegmentScores = find(hrT > TimeSegment(x) & ...
hrT < TimeSegment(x+1));
hrTre(x) = mean(HR(SegmentScores));
hrTime(x) = TimeSegment(x+1); % in seconds
end
%% Plot hrTre from each iteration on the same figure
hold on
plot(hrTime,hrTre);
end
end
我得到的图看起来在每次迭代中都具有完全相同的形状,并且一些迭代绘制在彼此之上,(即,具有相同的 xTime
值,这不应该发生)。我哪里出错了?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。