how do i plot the output with constant input

6 Ansichten (letzte 30 Tage)
grace lim
grace lim am 15 Feb. 2022
Kommentiert: Atsushi Ueno am 25 Feb. 2022
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 Kommentar
grace lim
grace lim am 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

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Atsushi Ueno
Atsushi Ueno am 15 Feb. 2022
Bearbeitet: Atsushi Ueno am 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 Kommentare
grace lim
grace lim am 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 am 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.

Melden Sie sich an, um zu kommentieren.


Arif Hoq
Arif Hoq am 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 Kommentare
Arif Hoq
Arif Hoq am 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 am 16 Feb. 2022
Bearbeitet: Arif Hoq am 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by