Creating a linear plot over a plot of giving numbers

조회 수: 2 (최근 30일)
Benjamin Shuey
Benjamin Shuey 2019년 2월 16일
답변: Star Strider 2019년 2월 16일
Currently I am having trouble trying to plot a function. Im trying to create 4 different subplots but I need this one line to be on it for comparison. So for the first sub plot i would have
x1= [10; 8; 13; 9; 11; 14; 6; 4; 12; 7; 5;]
y1= [8.04; 6.95; 7.58; 8.81; 8.33; 9.96; 7.24; 4.26; 10.84; 4.82; 5.68;]
subplot(2,2,1)
hold on
plot (x1,y1)
now with this i need to plot the line y=3+0.5x over a range 0 to 20. So far every attempt i have made has not worked.

답변 (1개)

Star Strider
Star Strider 2019년 2월 16일
Try this:
plot (x1,y1,'p')
hold on
plot([0 20], 3+0.5*[0 20])
hold off
It’s a linear function, so you only need the limits, not all the intermediate independent data.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by