how do i plot the output with constant input

6 ビュー (過去 30 日間)
grace lim
grace lim 2022 年 2 月 15 日
コメント済み: Atsushi Ueno 2022 年 2 月 25 日
This is my code:
y=Vonew %i get my Voutnew=45
plot( y, 'b-', 'LineWidth', 2);
xlabel('vin', 'FontSize', 20);
ylabel('vo', 'FontSize', 20);
title('vo vs vin', 'FontSize', 20);
I'm trying to plot vo vs vin, subing in vin=30 and vonew=45
Thank you in advance.
  1 件のコメント
grace lim
grace lim 2022 年 2 月 16 日
how do i plot 2 different point on the same line?
vin=0 vonew=0
vin=30 y=voutnew %vonew=45 from calculation
thank you in advance

サインインしてコメントする。

回答 (2 件)

Atsushi Ueno
Atsushi Ueno 2022 年 2 月 15 日
編集済み: Atsushi Ueno 2022 年 2 月 25 日
scatter function or yline function will match to your requirement.
x = [10 20 30 40 50]; y = [45 45 45 45 45]; %i get my Voutnew=45
scatter(x, y, 100, 'red', 'filled'); % to plot red filled circle at (30,45)
yline(y, 'b-', 'LineWidth', 2); % to draw a line at (:,45)
xlabel('vin', 'FontSize', 20);
ylabel('vo', 'FontSize', 20);
title('vo vs vin', 'FontSize', 20);
  3 件のコメント
grace lim
grace lim 2022 年 2 月 16 日
how do i plot 2 different points for example vin=30 and vin=10 and also v1new on the same line using the similar code?
Atsushi Ueno
Atsushi Ueno 2022 年 2 月 25 日
Instead of scalar values, you can input vector values x and vector y to scatter function. I have changed the answer above.

サインインしてコメントする。


Arif Hoq
Arif Hoq 2022 年 2 月 15 日
Vonew=45;
vin=30;
y=Vonew; %i get my Voutnew=45
plot( vin,y, 'o', 'LineWidth', 2);
xlabel('vin', 'FontSize', 20);
ylabel('vo', 'FontSize', 20);
title('vo vs vin', 'FontSize', 20);
  4 件のコメント
Arif Hoq
Arif Hoq 2022 年 2 月 16 日
2 different points..
Vonew=[45,50];
vin=30;
y=Vonew; %i get my Vonew=45
plot( vin,y,'o','Color','red','MarkerSize',10,'MarkerFaceColor','b','LineWidth', 2);
xline(vin, 'g', 'LineWidth', 2); % to draw a Vertical line with constant x-value
xlabel('vin', 'FontSize', 20);
ylabel('vo', 'FontSize', 20);
title('vo vs vin', 'FontSize', 20);
Arif Hoq
Arif Hoq 2022 年 2 月 16 日
編集済み: Arif Hoq 2022 年 2 月 16 日
or
Vonew=45;
vin=30;
y=Vonew; %i get my Vonew=45
x1=25;
y1=55;
% plot( vin,y,'o','Color','red','MarkerSize',10,'MarkerFaceColor','b','LineWidth', 2);
plot( vin,y,'o',x1,y1,'*','Color','red','MarkerSize',10,'MarkerFaceColor','b','LineWidth', 2);
xlim([15 40])
xline(vin, 'g', 'LineWidth', 2); % to draw a Vertical line with constant vin-value
xline(x1, 'b', 'LineWidth', 2); % to draw a Vertical line with constant x1-value
xlabel('vin', 'FontSize', 20);
ylabel('vo', 'FontSize', 20);
title('vo vs vin', 'FontSize', 20);
if you want to draw a Vertical line with constant x-value, use xline
if you want to draw a Vertical line with constant y-value, use yline

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by