How to draw this graph?

5 ビュー (過去 30 日間)
Yassin Issou
Yassin Issou 2020 年 6 月 9 日
編集済み: KSSV 2020 年 6 月 9 日
I want to draw something like this example, I mean without numbers in the axis but just x0 and x1, and with the functions shown only between x0 and x1.

採用された回答

KSSV
KSSV 2020 年 6 月 9 日
編集済み: KSSV 2020 年 6 月 9 日
Read about xticks for labelling x1, x2 along the axes. I have taken random points for plotting. You can take your required points to plot striaght line and the curve.
% Striaght line
L = rand(2,2) ;
% Curve passing through above two points
p = polyfit(L(:,1),L(:,2),3) ;
xi = linspace(min(L(:,1)),max(L(:,1))) ;
yi = polyval(p,xi) ;
%plot
figure
hold on
plot(L(:,1),L(:,2),'r')
plot(xi,yi,'b')
xlabel('x')
ylabel('y')
% Add text
text(mean(L(:,1)),mean(L(:,2))+0.02,'p(x)','FontSize',20)
text(mean(xi),mean(yi)-0.02,'f(x)','FontSize',20)

その他の回答 (1 件)

Kevin Joshi
Kevin Joshi 2020 年 6 月 9 日
You can use the 'XTick' and 'XTickLabel' as specified in,
https://in.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by