Why is line does not showing up on the plot?
53 ビュー (過去 30 日間)
古いコメントを表示
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)')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/412913/image.png)
0 件のコメント
採用された回答
Ameer Hamza
2020 年 11 月 13 日
編集済み: Ameer Hamza
2020 年 11 月 13 日
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)')
0 件のコメント
その他の回答 (1 件)
Cris LaPierre
2020 年 11 月 13 日
編集済み: Cris LaPierre
2020 年 11 月 13 日
Because fd contains a single value. This defines a point, not a line. Therefore, your code plots a single point at each t value, but they are not connected. You can see this by adding a line format spec that includes a marker to your plot command.
c = 3*10^8;
f0 = 10^9;
Vtarget = 10;
Vradar = 0;
fd = 2*(Vradar - Vtarget).*f0./c;
t= 0:100;
plot(t,fd,'r-o')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で View and Analyze Simulation Results についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!