用于在MATLAB图形中识别0和1的透明背景

用于在MATLAB图形中识别0和1的透明背景,matlab,matlab-figure,Matlab,Matlab Figure,我的代码中有阳光和日食检测。我想在我生成的每个图中突出显示日光和日食检测 假设 sun_avail = 0; % means spacecraft is in eclipse sun_avail = 1; % means spacecraft is in sunlit 我有一组变量(向量(X,Y,Z))需要在matlab图中绘制,我会这样做 fig = figure(); set(fig, 'name', 'Quaternions', 'NumberTitle', 'off'); subplo

我的代码中有阳光和日食检测。我想在我生成的每个图中突出显示日光和日食检测

假设

sun_avail = 0; % means spacecraft is in eclipse
sun_avail = 1; % means spacecraft is in sunlit
我有一组变量(向量(X,Y,Z))需要在matlab图中绘制,我会这样做

fig = figure();
set(fig, 'name', 'Quaternions', 'NumberTitle', 'off');
subplot(4,1,1);
plot(t,Qp(:,1),'b','linewidth',2);
title('Quaternions wrt ref frame selected','fontweight','b')
hold on;plot(t,q_dp(:,1),'-.m','linewidth',2);
grid;zoom;
legend('Gyro Q Attitude (Actual Gyro)','Body Q Attitude (Ideal Gyro)');
xlabel('time in secs','fontweight','b')
ylabel('q1','fontweight','b')

subplot(4,1,2);
plot(t,Qp(:,2),'b','linewidth',2);
hold on;plot(t,q_dp(:,2),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b'); 
ylabel('q2','fontweight','b')

subplot(4,1,3);
plot(t,Qp(:,3),'b','linewidth',2);
hold on;plot(t,q_dp(:,3),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b');
ylabel('q3','fontweight','b')

subplot(4,1,4);
plot(t,Qp(:,4),'b','linewidth',2);
hold on;plot(t,q_dp(:,4),'-.m','linewidth',2);
grid;zoom;
xlabel('time in secs','fontweight','b');
ylabel('q4','fontweight','b')

是否有任何方法可以像背景中的透明颜色一样高亮显示,以识别上图中的日光和日食部分。

您可以用于此目的。根据您的数据调整回路

plot(randperm(100));   hold on;    plot(randperm(100));  %plotting some random data      
%if sunlight remains for 20 units and 40 is the interval from which it repeats and
%100-20=80 is the last occurence then
for k=0:40:80  
    patch([k 20+k 20+k k], [0 0 100 100],'y','EdgeColor','none','FaceAlpha',0.3);
end  

你的意思是什么?是的,有点像那样repeats@SardarUsama,你能用更好的方式回答吗?参考此定义更好。由于在matlab中使用for循环处理500k的数据需要大量时间,如何避免使用for循环?