2017-10-02 3 views
0

코드에서 햇빛과 일식 감지를했습니다. 나는 모든 플롯에서 햇빛과 일식 감지를 강조하고 싶습니다.MATLAB 그림에서 0과 1의 식별을위한 투명한 배경

한다고 가정

나는 내가이

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') 

Figure looks like this처럼 할 거라고 matlab에 그림 플롯 할 필요가 변수 (벡터 (X, Y, Z))로 설정 한

sun_avail = 0; % means spacecraft is in eclipse 
sun_avail = 1; % means spacecraft is in sunlit 

위의 matlab 그림에서 햇볕에 쬐 인 부분과 일식 부분을 식별하기 위해 백그라운드에서 투명 색상처럼 강조 표시 할 수있는 방법이 있습니까?

+0

당신은 같은 의미 [*이 *] (https://i.stack.imgur.com/EkSRw.jpg)? –

+0

그와 같은 종류가 또한 반복됩니다 – Parvez

+0

@Sardar Usama, 당신은 더 나은 방법으로 대답 할 수 있습니까? 이 [MATLAB 플롯의 부분 강조 표시] (https://stackoverflow.com/questions/13734086/highlight-parts-of-matlab-plot) – Parvez

답변

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 

output