フィルターのクリア

Plot interval in y

4 ビュー (過去 30 日間)
Maria
Maria 2023 年 11 月 22 日
コメント済み: Sam Chak 2023 年 11 月 22 日
Hello, the question is, is it possible to set an interval in y when plotting a graph, if the interval is already set in x?
  3 件のコメント
Maria
Maria 2023 年 11 月 22 日
I have a task to build a graph of a trigonometric equation (cos(2*t))^(-2) - (sin(2*t))^(-2) =8/3), I build the graph as follows (I will attach part of the program) , but they told me that I need to limit the schedule by f, but I didn’t find information about this
t = 0:0.01:3*pi;
f= (cos(2*t)).^(-2) - (sin(2*t)).^(-2) - 8/3;
figure;
plot(t, f, 'LineWidth', 2);
xlabel('t');
ylabel('y');
title('График уравнения');
grid on;
Dyuman Joshi
Dyuman Joshi 2023 年 11 月 22 日
"but they told me that I need to limit the schedule by f"
I do not understand this. Can you explain a bit more about this?
Also, do you know what is the expected output? If yes, then please share.

サインインしてコメントする。

採用された回答

Sam Chak
Sam Chak 2023 年 11 月 22 日
The ylim() command can be used to set the interval on the y-axis.
x = -1:0.01:1;
y = x.^3 - 0.25*x.^2 - 0.5*x;
figure (1)
plot(x, y), grid on
figure (2)
plot(x, y), grid on, ylim([-0.4, 0.2])
  2 件のコメント
Maria
Maria 2023 年 11 月 22 日
Thank you it works @Sam Chak
Sam Chak
Sam Chak 2023 年 11 月 22 日
You are welcome, @Maria. If you find the solution helpful, please consider clicking 'Accept' ✔ on the answer and voting 👍 for it.
By the way, the function has singularities (division-by-zero events). That's why the plot shows the discontinuities.
t = 0:0.01:3*pi;
f = (cos(2*t)).^(-2) - (sin(2*t)).^(-2) - 8/3;
figure;
plot(t, f, 'LineWidth', 2);
ylim([-20 20])
xlabel('t');
ylabel('y');
title('График уравнения');
grid on;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by