I have already tried thetalim([-180 180]) but this command shows error in function file and not even show the half polar plot.
MATLAB: How to plot polar plot from -pi to pi instead of 0 to 2*pi
antennaMATLAB
Related Solutions
You are not passing theta_n and other parameters to root2d(). One fix is to make root2d a Nested Function. Also, you must choose a different initial point. phi0 = [10,10] worked for me.
function solve_it() beta_a = 10; alpha_n = 10 ; eta= 18; i = 18; theta_i = 10; theta_n = 10 ; fun = @root2d; phi0 = [10,10]; phi = fsolve(fun,phi0); phi_n = phi(1), phi_i = phi(2), function F = root2d(phi) F = zeros(2,1); F(1) = (pi*sin((pi*(phi(1) + theta_n))/180)*cos((pi*phi(2))/180)*(cos((pi*theta_n)/180) + tan((pi*i)/180)*tan((pi*theta_i)/180)))/(180*sin((pi*phi(1))/180)*(cos((pi*(phi(1) + theta_n))/180)*cos((phi(2)*pi)/180) + sin((phi(2)*pi)/180)*tan((theta_i*pi)/180))^2) - (pi*cos((pi*phi(1))/180)*(cos((pi*theta_n)/180) + tan((pi*i)/180)*tan((pi*theta_i)/180)))/(180*sin((phi(1)*pi)/180)^2*(cos((pi*(phi(1) + theta_n))/180)*cos((pi*phi(2))/180) + sin((pi*phi(2))/180)*tan((pi*theta_i)/180))); F(2) = ((cos((pi*theta_n)/180) + tan((pi*i)/180)*tan((pi*theta_i)/180))*((pi*cos((pi*(phi(1) + theta_n))/180)*sin((pi*phi(2))/180))/180 - (pi*cos((pi*phi(2))/180)*tan((pi*theta_i)/180))/180))/(sin((pi*phi(1))/180)*(cos((pi*(phi(1) + theta_n))/180)*cos((phi(2)*pi)/180) + sin((phi(2)*pi)/180)*tan((theta_i*pi)/180))^2); endend
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')
Best Answer