MATLAB: Error: Index exceeds the number of array elements (0) on the linspace function

linspace

I have a following part of a long code that plots two data, Variables (time, value) and frequency ( the same start and end of time of the variables but different values).
The code already does what I want, it plots so many figures until it stops with the following error at the fourth line of the code:
Index exceeds the number of array elements (0).
Error in duration/parenReference (line 17)
that.millis = this.millis(rowIndices);
Error in Erstellungderfrequenzinputbox (line 99)
ftime3=linspace(Uhrzeit(1),Uhrzeit(end),height(freqbereich3));
freq3 = freqbereich3.fb3;
freq3 = double(split(string(freq3(2:end-1)) , ","));
freq3 = freq3(:,1);
ftime3=linspace(Uhrzeit(1),Uhrzeit(end),height(freqbereich3));
freqbereich3.ftime3=ftime3';
nexttile
plot(ftime3(2:end-1),freq3);
hold on
plot(Uhrzeit,Wert)
Uhrzeit is the time and freqbereich3 are both all long tables with values that should have the same length or the same number of values that's why I used the linspace. Any solution or help?

Best Answer

ftime3=linspace(Uhrzeit(1),Uhrzeit(end),height(freqbereich3));
If Uhrzeit is empty then Uhrzeit(1) would be out of range.
Related Question