Error when using timetable/retime

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by