Concerning 1D data interpolation and use of Julian date function.

1 回表示 (過去 30 日間)
Amal Rai
Amal Rai 2020 年 1 月 6 日
回答済み: Walter Roberson 2020 年 1 月 25 日
%% Loading the datas :
load('In_Flight_Data.mat');
% Start and end dates for real-time datas obtained
DateStart = datetime('03/07/2019 17:00:00','InputFormat','dd/MM/uuuu HH:mm:ss');
DateEnd = datetime('04/07/2019 08:00:00','InputFormat','dd/MM/uuuu HH:mm:ss');
% Datas index you want to plot
idToPlot = [5];
datatimes = juliandate(dataTot(idat).Date(id)); % This contains the datetime values given in the first dataset.
timesim = juliandate(datethermica); %datethermica contains the datetime values given in the second dataset.
siminterpdata=interp1(timesim,datasim,datatimes); %This line gives an error
% Figure initialisation
figure
hold on
leg = {};
% Loop to plot the datas one by one
for i = 1:numel(idToPlot)
idat = idToPlot(i);
% Find the measurement points that are between the start and en dates
id = find((dataTot(idat).Date > DateStart) & (dataTot(idat).Date < DateEnd));
% Plot the data
plot(dataTot(idat).Date(id),dataTot(idat).Value(id));
plot(datethermica,Magneto_Board_12);
% Put some text in the leg array, which will be used as legend
leg{end+1} = dataTot(idat).Name;
end
% Format the graph
legend(leg); % give a ledgend
ylabel('Temperature (°C)'); % Give a label to Y axis
title('Temperatures'); % Give a title
Hello everyone,
From this plot, i'am obtaining two curves, i would like to do interpolation and for that i'am using interp1. Before this i have to convert the datetime data that i'am using into juliandate.
When i try to convert to juliandate:
1) I get an error at the line indicated in the code.
2) The values that i get from 'datasim' and 'timesim' are completely same, this i dont understand why.
.............................................................................................................................................................................
Here is the data:
1) The datetime data which has been plotted in the curves:
Datetime values
'2019-07-03T16:06:48'
'2019-07-03T16:08:48'
'2019-07-03T16:09:48'
'2019-07-03T16:10:48'
'2019-07-03T16:11:48'
'2019-07-03T16:12:48'
'2019-07-03T16:13:48'
'2019-07-03T16:14:48'
'2019-07-03T16:15:48'
'2019-07-03T16:16:48'
'2019-07-03T16:17:48'
'2019-07-03T16:18:48'
'2019-07-03T16:19:48'
'2019-07-03T16:20:48'
'2019-07-03T16:21:48'
'2019-07-03T16:22:48'
'2019-07-03T16:23:48'
'2019-07-03T16:24:48'
'2019-07-03T16:25:48'
'2019-07-03T16:26:48'
'2019-07-03T17:08:43'
'2019-07-03T17:11:43'
'2019-07-03T17:14:43'
'2019-07-03T17:17:43'
'2019-07-03T17:23:43'
'2019-07-03T17:29:44'
'2019-07-03T17:32:44'
'2019-07-03T17:35:44'
'2019-07-03T17:38:44'
'2019-07-03T17:41:44'
'2019-07-03T17:47:44'
'2019-07-03T17:50:44'
'2019-07-03T17:53:44'
'2019-07-03T17:56:44'
'2019-07-03T17:59:45'
'2019-07-03T18:02:45'
'2019-07-03T18:05:45'
'2019-07-03T18:08:45'
'2019-07-03T18:11:45'
'2019-07-03T18:14:45'
Temperature values
24
24
24
24
24
24
24
24
24
24
25
25
25
25
25
25
24
24
25
25
18
15
16
13
9
8
5
4
1
0
0
-1
-1
-1
2
3
4
6
5
7
This was the data for the blue curve seen in the graph.
........................................................................................................................................
Datetime values
'03-Jul-2019 10:00:00'
'03-Jul-2019 10:00:20'
'03-Jul-2019 10:00:40'
'03-Jul-2019 10:01:00'
'03-Jul-2019 10:01:20'
'03-Jul-2019 10:01:40'
'03-Jul-2019 10:02:00'
'03-Jul-2019 10:02:20'
'03-Jul-2019 10:02:40'
'03-Jul-2019 10:03:00'
'03-Jul-2019 10:03:20'
'03-Jul-2019 10:03:40'
'03-Jul-2019 10:04:00'
'03-Jul-2019 10:04:20'
'03-Jul-2019 10:04:40'
'03-Jul-2019 10:05:00'
'03-Jul-2019 10:05:20'
'03-Jul-2019 10:05:40'
'03-Jul-2019 10:06:00'
'03-Jul-2019 10:06:20'
'03-Jul-2019 10:06:40'
'03-Jul-2019 10:07:00'
'03-Jul-2019 10:07:20'
'03-Jul-2019 10:07:40'
'03-Jul-2019 10:08:00'
'03-Jul-2019 10:08:20'
'03-Jul-2019 10:08:40'
'03-Jul-2019 10:09:00'
'03-Jul-2019 10:09:20'
'03-Jul-2019 10:09:40'
'03-Jul-2019 10:10:00'
'03-Jul-2019 10:10:20'
'03-Jul-2019 10:10:40'
'03-Jul-2019 10:11:00'
'03-Jul-2019 10:11:20'
'03-Jul-2019 10:11:40'
'03-Jul-2019 10:12:00'
'03-Jul-2019 10:12:20'
'03-Jul-2019 10:12:40'
'03-Jul-2019 10:13:00'
Temperature values
25
24.7111000000000
24.3868000000000
24.0395000000000
23.6765000000000
23.3022000000000
22.9195000000000
22.5301000000000
22.1357000000000
21.7374000000000
21.3361000000000
20.9328000000000
20.5283000000000
20.1231000000000
19.7179000000000
19.3132000000000
18.9095000000000
18.5072000000000
18.1065000000000
17.7079000000000
17.3116000000000
16.9178000000000
16.5267000000000
16.1384000000000
15.7531000000000
15.3709000000000
14.9919000000000
14.6162000000000
14.2439000000000
13.8749000000000
13.5093000000000
13.1472000000000
12.7885000000000
12.4333000000000
12.0815000000000
11.7332000000000
11.3884000000000
11.0471000000000
10.7091000000000
10.3746000000000
This is the data for the Green curve in the graph.
......................................................................................................................
What i'am doing is first trying to convert these datatime values to juliandate and they are coming the same. And then there is the error at the line i indicated above. Also please tell me how i could interpolate after having resolved these issues.
  2 件のコメント
Steven Lord
Steven Lord 2020 年 1 月 6 日
What is the full and exact text of the error message you receive on that line? Include all the text displayed in red in a comment, and if you see any text displayed in orange include that text as well.
Amal Rai
Amal Rai 2020 年 1 月 7 日
>> Code_for_real_datas
Undefined function or variable 'datasim'.
Error in Code_for_real_datas (line 51)
siminterpdata=interp1(timesim,datasim,datatimes)
This is the error. How do i define datasim, i checked on MATLAB help and it shows that 'datasim' would contain the corresponding values of the sample points of 'timesim'. I don't understand.
Also, what about the Juliandate function, it is giving me the same values for both the datasets.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 1 月 25 日
Change
load('In_Flight_Data.mat');
To
Ds = load('In_Flight_Data.mat');
dataTot = Ds.dataTot;
datethermica = Ds.datethermica;
datasim = Ds.datasim;
That is, when you use load() without any output variable, newer versions of MATLAB are permitted to refuse to recognize any variable poofed into existence.
If datasim is not a variable inside your mat file then what exactly are you interpolating?

カテゴリ

Help Center および File ExchangeMeasurements and Feature Extraction についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by