![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010205/image.png)
How to plot a function
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I need to plot a graph with ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010160/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010160/image.png)
where x is between
and
,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010165/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010170/image.png)
y is here between
and
,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010175/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010180/image.png)
Can you help me with it?
Thanks
0 件のコメント
採用された回答
Sam Chak
2022 年 5 月 25 日
You can do something like this:
x = 0.1:0.01:10;
y1 = x.^(-2.9-0.1);
y2 = x.^(-2.9+0.1);
plot(x, y1, x, y2)
ylim([1e-8 1e0])
xlabel('x')
ylabel('y')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1010205/image.png)
2 件のコメント
Sam Chak
2022 年 5 月 25 日
That's strange... I've tested the code on both MATLAB and Octave. Try adding this:
clear all
close all
x = 0.1:0.01:10;
y1 = x.^(-2.9-0.1);
y2 = x.^(-2.9+0.1);
plot(x, y1, x, y2)
ylim([1e-8 1e0])
xlabel('x')
ylabel('y')
grid on
その他の回答 (1 件)
Fabio Freschi
2022 年 5 月 25 日
You may use fplot
figure, hold on
fplot(@(x)x.^-3,[1 1e5])
fplot(@(x)x.^-2.8,[1 1e5])
% use bi-logaritmic scale
set(gca,'YScale','log','xScale','log')
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!