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

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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2021년 3월 15일

답변:

2021년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by