0
我想绘制错误信号。当错误为零时,绘图应为黑色。每当出现错误时,它应该是红色的。我在数组excdIdx中捕获错误的索引。 我的目标是绘制红色和非黑色误差指数的误差指数。出于某种原因,for循环无法正常工作。使用matlab绘制不同颜色的选定索引
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](http://stackoverflow.com/help/mcve)。 – Matt