필터 지우기
필터 지우기

plot range -pi to pi

조회 수: 8 (최근 30일)
Abu Yamen
Abu Yamen 2016년 12월 2일
댓글: Abu Yamen 2016년 12월 3일
how we can plot sine, cosine and tangent on one Figure window ,my problem was the range --> -π < θ < π.
  댓글 수: 3
Roger Stafford
Roger Stafford 2016년 12월 2일
You can't do it! Over that range the tangent function becomes infinite-valued, so there is no way it could ever be completely plotted. You had better make some provision for avoiding such infinite or extremely large numbers in your plot.
Abu Yamen
Abu Yamen 2016년 12월 3일
when i select the rang the plot does not give cos or sin

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2016년 12월 2일
Try this:
% Initialization / clean-up code.
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 long g;
format compact;
fontSize = 20;
theta = linspace(-pi, pi, 1000);
period = 3*pi/4; % Whatever you want.
sint = sin(2 * pi * theta / period);
plot(theta, sint, 'b-', 'LineWidth', 2);
hold on;
cosinet = cos(2 * pi * theta / period);
plot(theta, cosinet, 'r-', 'LineWidth', 2);
tant = tan(2 * pi * theta / period);
plot(theta, tant, '-', 'Color', [0, 0.5, 0], 'LineWidth', 2);
grid on;
xlabel('Theta [in radians]', 'FontSize', fontSize);
ylabel('Amplitude (signal value)', 'FontSize', fontSize);
title('Trig functions versus Theta', 'FontSize', fontSize);
legend('Sine', 'Cosine', 'Tangent');
% The tangent spikes are so big that we can't see the sin and cosine.
% Let's limit the y range to +/- 4;
ylim([-4, 4]);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
  댓글 수: 1
Abu Yamen
Abu Yamen 2016년 12월 3일
perfect sir

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by