Error when using timetable/retime

3 ビュー (過去 30 日間)
Joel Schelander
Joel Schelander 2021 年 3 月 15 日
回答済み: Asvin Kumar 2021 年 3 月 18 日
I make a script that describes when EVs are charging during one year. I loop it for 429 cars.
However when car 8 is up this segment errors:
T=[];
%Create a time table which says what minute of the year that the car charges
for zeus=1:length(Chargingprofile)
if Chargingprofile(zeus,1)>0
x = [Chargingprofile(zeus,1) Chargingprofile(zeus,3); Chargingprofile(zeus,2) 0];
x = [x];
Tkk = timetable(minutes(x(:,1)),x(:,2));
Tkk.Var1(1:end-1) = Tkk.Var1(1:end-1) ./ minutes(diff(Tkk.Time));
Tkkk = retime(Tkk,'minutely','previous');
T=[T; Tkkk;];
end
end
-----------------
displaying this
Error using timetable/retime (line 140)
Interpolation requires at least two sample points in each dimension.
Error in MAIN (line 1148)
Tkkk = retime(Tkk,'minutely','previous');
---------------------
Tkk looks like this:
'1068 min' NaN
'1068 min' 0
I know that Tkk should look differently, NaN should be 0.1833 (as for all other cars) and the left column should contain a higher and a lower time value, but I dont know how to troubleshoot further
  1 件のコメント
Asvin Kumar
Asvin Kumar 2021 年 3 月 18 日
Running these two commands did not give me an error:
t=timetable(minutes([1068;1068]) ,[NaN;0])
retime(t,'minutely','previous')
Are you seeing an error with these same two commands? If yes, which version of MATLAB are you on?
If you aren't running into an error with the two commands I just posted, could you share any simple reproduction steps for your error?

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

採用された回答

Asvin Kumar
Asvin Kumar 2021 年 3 月 18 日
Ah, I had a second look. This is a known bug and is reproducible in R2019a. It was fixed in R2019b.
You could try one of two things:
  1. Make sure you don't send a NaN value into retime.
  2. Upgrade to a newer version of MATLAB.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by