Plotting complicated function with asymptotes
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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 件のコメント
Ben, are you still there? I haven't heard from you. What is this signal supposed to represent in the real world? Did my code work for you? I don't know what range you want to observe over - you did not say. Here is a full demo showing the plot over the 0 to 3*pi range.
% Initialization steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 18;
y = linspace(0, 3*pi, 1000);
signal = exp(y .* cot(y)) .* sin(y);
% signal = cot(y);
plot(y, signal, 'b-', 'LineWidth', 2);
grid on;
xlabel('y', 'FontSize', fontSize);
ylabel('Signal', 'FontSize', fontSize);
ylim([-1, 1.8]);
title('signal = exp(y .* cot(y)) .* sin(y)', 'FontSize', fontSize);

Is this what you wanted? Please let me know.
Ben Phelps
2021 年 3 月 1 日
Hi,
Thanks for this. This unfortunately still shows the asymptotes, I am looking for a way to plot this without it showing the asymptotes as I need it to identify points of intersection with another function.
Image Analyst
2021 年 3 月 1 日
What part of the signal is NOT part of an asymptote? Can you mock up a graph for what you'd like it to look like so I can see what parts of the curve should be plotted and what parts should not be plotted?
By the way, to have it not plot some points, you can replace those points with NaN.
And are you going to answer my questions about what this equation describes, and the vertical and horizontal ranges over which you'd like to view it?
Ben Phelps
2021 年 3 月 1 日
I am trying to recreate this figure. The solid line is the function in question.

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
2021 年 3 月 1 日
Thankyou so much this is perfect!
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
