필터 지우기
필터 지우기

How can I modify negative values from two datasets based on a positive given one?

조회 수: 1 (최근 30일)
Kofial
Kofial 2020년 11월 19일
댓글: Kofial 2020년 11월 20일
Hi. I need some help.
I wrote this code to fix two datas(First_data,Second_data) based on another one(Third_data). The datasets have the same trend, so the graph should look similar(not identic).
The code looks that it works when the values are positive but not on negative ones.
DateO={'20-Apr-2020 12:06:00','20-Apr-2020 12:07:00','20-Apr-2020 12:08:00','20-Apr-2020 12:09:00','20-Apr-2020 12:10:00','20-Apr-2020 12:11:00','20-Apr-2020 12:12:00','20-Apr-2020 12:13:00'};
DateT={'20-Apr-2020 12:06:00','20-Apr-2020 12:07:00','20-Apr-2020 12:08:00','20-Apr-2020 12:09:00','20-Apr-2020 12:10:00','20-Apr-2020 12:11:00','20-Apr-2020 12:12:00','20-Apr-2020 12:13:00'};
DateTh={'20-Apr-2020 12:06:30','20-Apr-2020 12:07:30','20-Apr-2020 12:08:30','20-Apr-2020 12:09:30','20-Apr-2020 12:10:30','20-Apr-2020 12:11:30','20-Apr-2020 12:12:30','20-Apr-2020 12:13:30'}; % Picarro
A = datetime(DateO,'InputFormat','dd-MM-yyyy HH:mm:ss');
B = datetime(DateT,'InputFormat','dd-MM-yyyy HH:mm:ss');
C = datetime(DateTh,'InputFormat','dd-MM-yyyy HH:mm:ss');
First_data=[-216,-220,-225,-232,-233,-233,-244,-246];
Second_data=[89,66,30,7,9.6,-5.8,-12,-16];
Third_data=[7.59,3.52,3.8,3.21,2,3.42,2.3,4.36];
figure;
left={Third_data,Third_data};
right={First_data,Second_data};
right_time = {A, B};
xlab=["Third data"," Third data"];
ylab=["First data","Second data"];
for i=1:length(left)
x = left{i};
y = right{i};
t = right_time{i};
if i == 1
Coeff(i) = max(y)/max(x);
else
Coeff(i) = max(x)/max(y);
end
y(y>0) = y(y>0).*Coeff(i);
y(y<0) = y(y<0).*Coeff(i);
Clb_values{i} = y;
Clb = Clb_values{i};
subplot(2,1,1*i);
yyaxis left;
plot(C, x);
ylabel('Third_data')
yyaxis right;
plot(t,Clb);
ylabel(ylab(i))
end
Clb_1=Clb_values{1,1};
Clb_2=Clb_values{1,2};
Thank you
  댓글 수: 5
Matt J
Matt J 2020년 11월 20일
The coffee for the first data is negative...
Even better than decaf!

댓글을 달려면 로그인하십시오.

답변 (1개)

Nora Khaled
Nora Khaled 2020년 11월 20일
maybe this works ?
if i == 1
y=y+(x-y);
Coeff(i) = abs(max(y)/max(x));
else
Coeff(i) = abs(max(x)/max(y));
end
  댓글 수: 1
Kofial
Kofial 2020년 11월 20일
I tried this and the "First data" becomes identic with the "Third data". This means that something is still wrong. Should be something to do with the coffee...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by