Plotting graphs with setting my own scales
1 回表示 (過去 30 日間)
古いコメントを表示
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/540406/image.jpeg)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/540391/image.jpeg)
Can anyone please help me out? Thanks.
0 件のコメント
採用された回答
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 件のコメント
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 Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!