【发布时间】:2015-08-15 19:46:08
【问题描述】:
我正在尝试绘制错误信号。当误差为零时,绘图应为黑色。每当出现错误时,它应该是红色的。我在数组 excdIdx 中捕获有错误的索引。 我的目标是用红色绘制错误索引,用黑色绘制非错误索引。由于某种原因,for 循环不起作用。
ErrAxis 是轴 excdIdx 包含要绘制成红色的索引列表
h(8) = subplot(plotCount,1,ErrAxis);
hold off;
if excdIdx > 0
plot(time(1:excdIdx),Output(1:excdIdx) - trueSignal(1:excdIdx),'k-'); hold on;
%this method to plot the error indices in red is not working
% for elem = 1: size(excdIdx, 2)
% index_1 = excdIdx(elem);
% index_2 = excdIdx(elem+1);
% plot(time(index_1:index_1+1),Output(index_1:index_1+1) - trueSignal(index_1:index_1+1),'r-'); hold on;
% end
else
plot(time,Output - trueSignal,'k-'); hold on;
end
【问题讨论】:
-
能否请您创建一个MCVE。
标签: matlab plot colors subplot