How can I modify negative values from two datasets based on a positive given one?
2 ビュー (過去 30 日間)
表示 古いコメント
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
回答 (1 件)
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
参考
カテゴリ
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!