Plotting complicated function with asymptotes
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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.
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.
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?
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.
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
