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 CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by