how do i plot the output with constant input

7 views (last 30 days)
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 Comment
grace lim
grace lim on 16 Feb 2022
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

Sign in to comment.

Answers (2)

Atsushi Ueno
Atsushi Ueno on 15 Feb 2022
Edited: Atsushi Ueno on 25 Feb 2022
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 Comments
grace lim
grace lim on 16 Feb 2022
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 on 25 Feb 2022
Instead of scalar values, you can input vector values x and vector y to scatter function. I have changed the answer above.

Sign in to comment.


Arif Hoq
Arif Hoq on 15 Feb 2022
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 Comments
Arif Hoq
Arif Hoq on 16 Feb 2022
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 on 16 Feb 2022
Edited: Arif Hoq on 16 Feb 2022
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

Sign in to comment.

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!