Error when using timetable/retime

2 views (last 30 days)
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 Comment
Asvin Kumar
Asvin Kumar on 18 Mar 2021
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?

Sign in to comment.

Accepted Answer

Asvin Kumar
Asvin Kumar on 18 Mar 2021
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.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!