
plotting a straight line with slope and a single point
조회 수: 2 (최근 30일)
이전 댓글 표시
Greetings,
I am trying to plot the following items with given slope and x,y coordinate (single points)
%%%Y-Values
Stress_fail_GF=2.1;
Stress_fail_AF=2.8;
Stress_fail_Matrix=0.1;
%%%X-Value
Strain_fail_GF=.0054;
Strain_fail_AF=.021;
Strain_fail_Matrix=.33;
%%%Modulus - Slope
GF_Modulus=Stress_fail_GF/Strain_fail_GF;
AF_Modulus=Stress_fail_AF/Strain_fail_AF;
Matrix_Modulus=Stress_fail_Matrix/Strain_fail_Matrix;
%%% I tested the following, but it provides a blank graph
x = Stress_fail_GF;
m = GF_Modulus;
b = Strain_fail_GF;
y = m*x + b;
figure(1)
plot(x, y)
grid
댓글 수: 0
답변 (1개)
Gautam
2024년 8월 22일
Hello Eddy,
I understand that you are expecting a linear plot as the outcome of your graphing. The reason you don’t get a linear plot is because you are plotting a single data point which gets plotted on the graph. The graph is indeed not blank but plots a single data point. You can view this by making the marker visible:
plot(x, y, 'o');
Which gives the plot:

To plot a straight line, you need a range of x values which you can use to get the y values from the slope and intercept data that you have.
Hope this helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!