Your problem lies in your assumptions. Try this example:
t = 0:10
t =
0 1 2 3 4 5 6 7 8 9 10
y = 1;
plot(t,y,'r--')
Nothing appears in the plot, but you assume that it should do something logical. As it turns out, plot does effectively nothing visible when you try to plot a scalar versus a vector like this. (To be honest, I would rather see this return an error than do what appears to be essentially nothing. At least it would be nice if plot returned a warning message that alerts the user to the issue.) In fact though, it does create a plot, or it tries to do so.
h = get(gca,'children')
h =
11×1 Line array:
Line
Line
Line
Line
Line
Line
Line
Line
Line
Line
Line
So, what did it do? When I look at the handles returned here, I see they represent 11 separate, distinct "lines", but each line is only a single point.
h(1)
ans =
Line with properties:
Color: [1 0 0]
LineStyle: '--'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: 10
YData: 1
ZData: [1×0 double]
Show all properties
So, it plotted the value in y against each of the elements of t, creating 11 distinct "lines", each of length zero. Since no line segments were ever created, then we saw no lines connecting the dots. This also explains why, when you try effectively this:
it produces a quasi-"line" but with only the points plotted.
I've gone into a bit of depth here to explain what MATLAB did, and why it misunderstood what you tried to do.
Now, how should you fix it? That is far simpler than the explanation I gave.
plot(t,repmat(y,size(t)),'r--')
Essentially, you need to make y the same size as the first argument, so it now understands that you want to create a line as connect the dots, using a '--' linestyle. REPMAT suffices for that purpose, as I did here.