2 unknowns in matching datasets
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone.
I have 3 sets of data and need to find "a" and "b":
Y1=a*Y2+b*Y3;
there are 2 unknowns so I would need 2 equations to solve this but maybe there is a way to solve this as is? Help please.
Thank you
댓글 수: 0
채택된 답변
DGM
2022년 4월 25일
편집: DGM
2022년 4월 25일
I'm sure there are other ways, but:
load datasett.mat
% omit nans
nanmask = ~(isnan(Y1) | isnan(Y2) | isnan(Y3));
Y1 = Y1(nanmask);
Y2 = Y2(nanmask);
Y3 = Y3(nanmask);
% when overdefined, mldivide returns the least-squares solution
ab = [Y2 Y3]\Y1
That said, I'm not sure it's going to be good enough to just blindly process the data. Y1 doesn't look like the linear combination of Y2 and Y3 (at least it doesn't respond events in Y2).
Y1est = [Y2 Y3]*ab; % assume that Y1 is a linear combination
subplot(2,1,1)
plot(Y2); hold on
plot(Y3)
subplot(2,1,2)
plot(Y1); hold on
plot(Y1est)
Some sort of preprocessing is probably warranted here.
댓글 수: 3
DGM
2022년 4월 25일
If the data is taken at face value, Y1 isn't a linear combination of Y2 and Y3. That should be visually apparent just by looking at the graphs.
If the underlying system is expected to be linear, then you'll have to find an appropriate way to deal with the noise events in Y1 and Y2. I'm not sure what would be appropriate. You might try omitting outliers, filling them, or smoothing them.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!