我的代码中有阳光和日食检测。我想在我生成的每个情节中强调阳光和日食检测。
假设
sun_avail = 0; % means spacecraft is in eclipse
sun_avail = 1; % means spacecraft is in sunlit
我需要在matlab图中绘制一组变量(向量(X,Y,Z)),我这样做
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')
是否有任何方法可以突出显示背景中的透明色,以识别上述matlab图中的阳光和日食部分。
答案 0 :(得分:1)
您可以使用patch
来实现此目的。根据您的数据调整循环。
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