Currently, you are plotting (x, y, z) data as you would on a Cartesian axes. If you want to combine this with (lat, lon) data, you need to somehow convert between the two.
For example, you could use the geodetic2ecef function from Mapping Toolbox to convert from (lat, lon) coordinates to (x, y, z) coordinates:
[X, Y, Z] = geodetic2ecef(E, coastlat, coastlon, 0);
plot3(X, Y, Z, "Color", "red", "LineWidth", 5);
Alternatively, you could consider sticking with (lat, lon) data exclusively and using something like geoglobe:
f = uifigure();
g = geoglobe(f);
geoplot3(g, coastlat, coastlon, 0, "Color", "red", "LineWidth", 5);
In either case, it's critical to pay attention to the coordinate system that you are working in.