Plotting graphs with setting my own scales

조회 수: 1 (최근 30일)
Hmm!
Hmm! 2021년 3월 5일
댓글: the cyclist 2021년 3월 6일
I plotted these nonlinear functions
fplot (@ (x)x^2 -2)
hold on
fplot (@(x) sqrt(x+2))
hold on
fplot (@(x) (x^2 + 2)/(2*x-1) )
hold on
fplot (@(x) (x^2 + 2)/(2*x-1) )
hold on
fplot (@(x) 1*x )
hold off
grid on
I donot like MATLAB's build in scaling. I want the scales to be something like 2cm to 1 unit on both axes so that the plot will look exactly like this:
Can anyone please help me out? Thanks.

채택된 답변

the cyclist
the cyclist 2021년 3월 6일
편집: the cyclist 2021년 3월 6일
figure
hold on
fplot (@ (x)x.^2 -2)
fplot (@(x) sqrt(x+2))
fplot (@(x) (x.^2 + 2)./(2*x-1) )
fplot (@(x) (x.^2 + 2)./(2*x-1) )
fplot (@(x) 1*x )
grid on
xlim([0 3.2])
ylim([0 3.2])
axis square
This is not quite exactly the same, but it's a lot closer. Good enough?
Note that you also had some matrix multiplication and division in your function definitions, which I assume was not intended. Take note of the changes I made.
  댓글 수: 3
Hmm!
Hmm! 2021년 3월 6일
편집: Hmm! 2021년 3월 6일
Why is there a dash-dash vertical line at ? My plot also has two of these lines at
the cyclist
the cyclist 2021년 3월 6일
As described in the this documentation, fplot will display the asymptote of some functions. You can turn this behavior on or off with the 'showpoles' input:
figure
fplot (@(x) (x.^2 + 2)./(2*x-1), 'showpoles','on' )
figure
fplot (@(x) (x.^2 + 2)./(2*x-1), 'showpoles','off' )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by