MATLAB: Is line does not showing up on the plot

lineplot

I'm trying to plot a line but it's not working. Here's an example of what doesn't work:
c = 3*10^8;
f0 = 10^9;
Vtarget = 10;
Vradar = 0;
fd = 2*(Vradar - Vtarget).*f0./c;
t= 0:100;
plot(t,fd)
title('Doppler Frequency Change')
xlabel('Time(sec)')
ylabel('Doppler Frequency(Hertz)')

Best Answer

t is a vector, whereas fd is a scalar. How do you want to plot these two? As a straight line? If yes, then try this
c = 3*10^8;
f0 = 10^9;
Vtarget = 10;
Vradar = 0;
fd = 2*(Vradar - Vtarget).*f0./c;
t= 0:100;
plot(t,fd*ones(size(t)))
title('Doppler Frequency Change')
xlabel('Time(sec)')
ylabel('Doppler Frequency(Hertz)')
You can also use yline()
c = 3*10^8;
f0 = 10^9;
Vtarget = 10;
Vradar = 0;
fd = 2*(Vradar - Vtarget).*f0./c;
t= 0:100;
yline(fd)
title('Doppler Frequency Change')
xlabel('Time(sec)')
ylabel('Doppler Frequency(Hertz)')