Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

다중 실험 데이터 및 모델 병합 처리하기

이 예제에서는 System Identification Toolbox™를 사용하여 모델을 추정하고 미세 조정할 때 다중 실험 및 모델 병합을 처리하는 방법을 보여줍니다.

소개

System Identification Toolbox의 분석 함수와 추정 함수를 사용하여 여러 데이터 배치로 작업할 수 있습니다. 특히 다중 실험을 수행하고 여러 개의 입력-출력 데이터 세트를 기록한 경우, 이를 단일 IDDATA 객체로 그룹화하여 원하는 추정 루틴에서 사용할 수 있습니다.

경우에 따라, (단일) 측정값 데이터 세트를 "분할"하여 데이터 품질이 떨어지는 부분을 제거할 수 있습니다. 예를 들어 외부적인 외란이나 센서 장애로 인해 데이터의 일부분이 불안정할 수 있습니다. 이런 경우, 데이터에서 양호한 각 부분을 분리한 후 다중 실험 IDDATA 객체 하나에 결합할 수 있습니다.

예를 들어 데이터 세트 iddemo8data.mat를 살펴보겠습니다.

load iddemo8data

데이터 객체의 이름은 dat이고 아래와 같습니다.

dat
dat =

Time domain data set with 1000 samples.
Sample time: 1 seconds                  
                                        
Outputs      Unit (if specified)        
   y1                                   
                                        
Inputs       Unit (if specified)        
   u1                                   
                                        
plot(dat)

Figure contains 2 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents dat. Axes object 2 with title u1 contains an object of type line. This object represents dat.

샘플 250~280과 샘플 600~650 근방에서 출력에 문제가 있는 것을 알 수 있습니다. 이러한 문제는 센서 장애로 인해 나타난 문제일 수 있습니다.

따라서 데이터를 세 개의 개별 실험으로 분할한 후 다중 실험 데이터 객체 하나에 삽입합니다.

d1 = dat(1:250);
d2 = dat(281:600);
d3 = dat(651:1000);
d = merge(d1,d2,d3) % merge lets you create multi-exp IDDATA object
d =
Time domain data set containing 3 experiments.

Experiment   Samples      Sample Time          
   Exp1         250            1               
   Exp2         320            1               
   Exp3         350            1               
                                               
Outputs      Unit (if specified)               
   y1                                          
                                               
Inputs       Unit (if specified)               
   u1                                          
                                               

아래와 같이 다른 실험에는 다른 이름을 지정할 수 있습니다.

d.exp = {'Period 1';'Day 2';'Phase 3'}
d =
Time domain data set containing 3 experiments.

Experiment     Samples      Sample Time        
   Period 1       250            1             
   Day 2          320            1             
   Phase 3        350            1             
                                               
Outputs        Unit (if specified)             
   y1                                          
                                               
Inputs         Unit (if specified)             
   u1                                          
                                               

검토하려면 plot(d)에서처럼 플롯을 사용합니다.

다중 실험 데이터를 사용하여 추정 수행하기

앞에서 설명한 대로, 모든 모델 추정 루틴은 다중 실험 데이터를 받아들이며 데이터가 서로 다른 기간에 기록된다는 점을 고려합니다. 처음 두 실험은 추정에 사용하고 세 번째 실험은 검증에 사용하겠습니다.

de = getexp(d,[1,2]);      % subselection is done using  the command GETEXP 
dv = getexp(d,'Phase 3');  % using numbers or names.
m1 = arx(de,[2 2 1]);
m2 = n4sid(de,2);
m3 = armax(de,[2 2 2 1]);
compare(dv,m1,m2,m3)

Figure contains an axes object. The axes object with ylabel y1 contains 4 objects of type line. These objects represent Validation data (y1), m1: 73.05%, m2: 80.01%, m3: 80.09%.

compare 명령도 다중 실험을 받아들입니다. 사용할 실험을 한 번에 하나씩 선택하려면 오른쪽 버튼 클릭 메뉴를 사용합니다.

compare(d,m1,m2,m3)

Figure contains an axes object. The axes object with ylabel y1 contains 4 objects of type line. These objects represent Validation data:Period 1 (y1), m1: 74.2%, m2: 80.41%, m3: 80.35%.

또한 spa, etfe, resid, predict, sim은 다중 실험 데이터에서도 단일 실험 데이터에서와 동일한 방식으로 작동됩니다.

모델 추정 후 병합하기

개별 데이터 세트를 처리하는 또 다른 방법은 각 데이터 세트에 대해 모델을 계산한 후 모델을 병합하는 것입니다.

m4 = armax(getexp(de,1),[2 2 2 1]);
m5 = armax(getexp(de,2),[2 2 2 1]);
m6 = merge(m4,m5); % m4 and m5 are merged into m6

이 방법은 병합된 세트 de에서 m을 계산하는 것과 개념상 동일하지만 수치적으로는 동일하지 않습니다. de 작업에서는 서로 다른 실험에서 신호 대 잡음비가 (거의) 동일하다고 가정하지만, 개별 모델을 병합하면 잡음 수준을 독립적으로 추정할 수 있습니다. 서로 다른 실험에서 조건이 거의 동일한 경우 다중 실험 데이터에 대해 직접 추정하는 것이 훨씬 효율적입니다.

다음 두 가지 방법으로 동일한 데이터에서 얻은 ARMAX 모델인 m3m6 모델을 검사할 수 있습니다.

[m3.a;m6.a]
ans = 2×3

    1.0000   -1.5034    0.7008
    1.0000   -1.5022    0.7000

[m3.b;m6.b]
ans = 2×3

         0    1.0023    0.5029
         0    1.0035    0.5028

[m3.c;m6.c]
ans = 2×3

    1.0000   -0.9744    0.1578
    1.0000   -0.9751    0.1584

compare(dv,m3,m6)

Figure contains an axes object. The axes object with ylabel y1 contains 3 objects of type line. These objects represent Validation data (y1), m3: 80.09%, m6: 80.09%.

사례 연구: 독립 데이터 세트의 결합 대 병합

이제 다른 상황으로 전환해 보겠습니다. 시스템 m0에서 생성된 두 개의 데이터 세트가 있다고 가정해 보겠습니다. 시스템은 다음과 같이 주어집니다.

m0
m0 =
  Discrete-time identified state-space model:
    x(t+Ts) = A x(t) + B u(t) + K e(t)
       y(t) = C x(t) + D u(t) + e(t)
 
  A = 
             x1        x2        x3
   x1    0.5296    -0.476    0.1238
   x2    -0.476  -0.09743    0.1354
   x3    0.1238    0.1354   -0.8233
 
  B = 
             u1        u2
   x1    -1.146  -0.03763
   x2     1.191    0.3273
   x3         0         0
 
  C = 
            x1       x2       x3
   y1  -0.1867  -0.5883  -0.1364
   y2   0.7258        0   0.1139
 
  D = 
          u1     u2
   y1  1.067      0
   y2      0      0
 
  K = 
       y1  y2
   x1   0   0
   x2   0   0
   x3   0   0
 
Sample time: 1 seconds

Parameterization:
   STRUCTURED form (some fixed coefficients in  A, B, C).
   Feedthrough: on some input channels
   Disturbance component: none
   Number of free coefficients: 23
   Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties.

Status:                                                         
Created by direct construction or transformation. Not estimated.
 

수집한 데이터 세트는 서로 다른 입력, 잡음 및 초기 조건을 사용하여 m0으로부터 얻은 z1z2입니다. 이러한 데이터 세트는 앞에서 불러온 iddemo8data.mat에서 얻습니다.

첫 번째 데이터 세트:

plot(z1) 

Figure contains 4 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents z1. Axes object 2 with title y2 contains an object of type line. This object represents z1. Axes object 3 with title u1 contains an object of type line. This object represents z1. Axes object 4 with title u2 contains an object of type line. This object represents z1.

두 번째 데이터 세트:

plot(z2)

Figure contains 4 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents z2. Axes object 2 with title y2 contains an object of type line. This object represents z2. Axes object 3 with title u1 contains an object of type line. This object represents z2. Axes object 4 with title u2 contains an object of type line. This object represents z2.

얻은 데이터를 결합만 하는 경우:

zzl = [z1;z2]
zzl =

Time domain data set with 400 samples.
Sample time: 1 seconds                 
                                       
Outputs      Unit (if specified)       
   y1                                  
   y2                                  
                                       
Inputs       Unit (if specified)       
   u1                                  
   u2                                  
                                       
plot(zzl)

Figure contains 4 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents zzl. Axes object 2 with title y2 contains an object of type line. This object represents zzl. Axes object 3 with title u1 contains an object of type line. This object represents zzl. Axes object 4 with title u2 contains an object of type line. This object represents zzl.

이산시간 상태공간 모델은 ssest를 사용하여 얻을 수 있습니다.

ml = ssest(zzl,3,'Ts',1, 'Feedthrough', [true, false]);

m0 모델 및 ml 모델에 대한 보드 응답을 비교합니다.

clf
bode(m0,ml)
legend('show')

Figure contains 8 axes objects. Axes object 1 with title From: u1, ylabel To: y1 contains 2 objects of type line. These objects represent m0, ml. Axes object 2 with ylabel To: y1 contains 2 objects of type line. These objects represent m0, ml. Axes object 3 with ylabel To: y2 contains 2 objects of type line. These objects represent m0, ml. Axes object 4 with ylabel To: y2 contains 2 objects of type line. These objects represent m0, ml. Axes object 5 with title From: u2 contains 2 objects of type line. These objects represent m0, ml. Axes object 6 contains 2 objects of type line. These objects represent m0, ml. Axes object 7 contains 2 objects of type line. These objects represent m0, ml. Axes object 8 contains 2 objects of type line. These objects represent m0, ml.

이 모델은 위의 네 가지 보드 플롯에서 관찰할 수 있듯이 썩 좋은 모델은 아닙니다.

대신, 이제 두 데이터 세트를 서로 다른 실험으로 취급합니다.

zzm = merge(z1,z2)
zzm =
Time domain data set containing 2 experiments.

Experiment   Samples      Sample Time          
   Exp1         200            1               
   Exp2         200            1               
                                               
Outputs      Unit (if specified)               
   y1                                          
   y2                                          
                                               
Inputs       Unit (if specified)               
   u1                                          
   u2                                          
                                               
% The model for this data can be estimated as before (watching progress this time)
mm = ssest(zzm,3,'Ts',1,'Feedthrough',[true, false], ssestOptions('Display', 'on'));

Let us compare the Bode plots of the true system (blue)

the model from concatenated data (green) and the model from the

merged data set (red):

clf
bode(m0,'b',ml,'g',mm,'r')
legend('show')

Figure contains 8 axes objects. Axes object 1 with title From: u1, ylabel To: y1 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 2 with ylabel To: y1 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 3 with ylabel To: y2 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 4 with ylabel To: y2 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 5 with title From: u2 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 6 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 7 contains 3 objects of type line. These objects represent m0, ml, mm. Axes object 8 contains 3 objects of type line. These objects represent m0, ml, mm.

병합된 데이터는 위의 플롯에서 관찰할 수 있듯이 더 나은 모델을 제공합니다.

결론

이 예제에서는 한 모델의 추정을 위해 여러 데이터 세트를 함께 사용하는 방법을 분석했습니다. 이 기법은 독립 실험 실행에서 생성된 여러 데이터 세트가 있을 때 또는 데이터를 여러 세트로 분할하여 잘못된 부분을 제거할 때 유용합니다. 다중 실험을 단일 IDDATA 객체에 패키징할 수 있으며, 이는 모든 추정 및 분석 요구 사항에서 유용합니다. 이 기법은 시간 영역 및 주파수 영역 iddata에서 모두 작동합니다.

또한 모델을 추정한 후 병합할 수도 있습니다. 이 기법은 독립적으로 추정된 모델의 "평균을 계산"하는 데 사용할 수 있습니다. 다중 데이터 세트에 대한 잡음 특성이 서로 다른 경우, 추정 전에 데이터 세트 자체를 병합하는 것보다 추정 후 모델을 병합하는 것이 훨씬 효과적입니다.

관련 항목