Creating horizontal regions between functions
1 回表示 (過去 30 日間)
古いコメントを表示
I tried doing it, but i kept getting it wrong, can you help and tell me what my mistake is.
f = @(x) cos(x);
g = @(x) x-x;
a = 0;
b =1;
fplot(f, [a, pi/2]), hold on
fplot(g, [a, pi/2], 'LineWidth',2)
ycoord = linspace(a, b, 20);
xcoord = [f(ycoord); g(ycoord)];
plot(xcoord, [ycoord;ycoord]), hold off
I used this code^^
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1181648/image.png)
but i want this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1181653/image.png)
thanks.
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 11 月 4 日
Consider the top red line that you want. The x coordinates of the line should start from 0, but should end at the point where cos(x) = 0.95. So for any particular y coordinate, the ending x coordinate should be acos(y)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!