Plotting complicated function with asymptotes

18 ビュー (過去 30 日間)
Ben Phelps
Ben Phelps 2021 年 2 月 28 日
コメント済み: Ben Phelps 2021 年 3 月 1 日
Hi,
I am struggling to plot this equation in Matlab
I have tried using plot, fplot and ezplot but none seem to be able to handle it. Would anyone be able to help me with this?

採用された回答

Image Analyst
Image Analyst 2021 年 2 月 28 日
Did you try
y = linspace(7, 12, 1000);
signal = exp(y .* cot(y)) .* sin(y);
plot(y, signal, 'b-', 'LineWidth', 2);
grid on;
xlabel('y');
ylabel('Signal');
  6 件のコメント
Image Analyst
Image Analyst 2021 年 3 月 1 日
編集済み: Image Analyst 2021 年 3 月 1 日
y = linspace(0, 16, 2000);
signal = exp(y .* cot(y)) .* sin(y);
% Get rid of vertical "asymptotes" by setting anything outside our viewing range to nan.
nanIndexes = signal > 100;
signal(nanIndexes) = nan;
% Plot signal in solid black line.
plot(y, signal, 'k-', 'LineWidth', 2);
grid on;
xlabel('N', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
ylim([-10, 40]);
title('signal = exp(y .* cot(y)) .* sin(y)', 'FontSize', fontSize);
% Plot dashed line from (0, 0) to (7.5, 40);
hold on;
plot([0, 7.5], [0, 40], 'k--', 'LineWidth', 2);
% Plot dashed line from (0, 0) to (16, 15);
plot([0, 16], [0, 15], 'k--', 'LineWidth', 2);
% Make a black line along the x axis
yline(0, 'LineWidth', 2);
If that solves it, could you please "Accept this answer"? Thanks in advance.
Ben Phelps
Ben Phelps 2021 年 3 月 1 日
Thankyou so much this is perfect!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by