How can I plot a constant value versus a range of values?

9 ビュー (過去 30 日間)
Zachary McBurney
Zachary McBurney 2020 年 5 月 1 日
編集済み: Adam Danz 2020 年 5 月 4 日
Apologies I am relativey new to using Matlab. I am trying to make a plot of these variables (g versus omega). g is a constant value while omega is a range of values between 0 and 20000 with an increment of 20 to produce 1000 points. Is this even possible? I am needing to do this using the plot command as well as the loglog or logspace commands.
omega= 0:20:20000;
Vs=cos(omega)
VL=17.04*Vs
g= VL/Vs

回答 (1 件)

Adam Danz
Adam Danz 2020 年 5 月 1 日
編集済み: Adam Danz 2020 年 5 月 4 日
plot(g,omega,'o')
% or
plot(repmat(g,size(omega)),omega,'-')
Since g is a scalar (single value), you'll just have a vertical line (or a horizontal line if 'g' is the y-value). So, you could simplify the line with,
plot([g,g], [min(omega),max(omega)], 'o-')

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by