MATLAB: R=e^(cos*theta)-2*cos(4*theta) graphic on MATLAB equationexpMATLABtheta I want to do the graphic of this equation in matlab but i can't make it work, can someone help me please? this is my code so far: theta=linspace(-pi,pi,100); r = exp(theta)-2*cos(4*theta); polar(theta,r); Best Answer I got the graph and it is the same in Wolfram alpha there is nothing wrong with it.%EDITED after the remark by JOHN D'ERRICO Related SolutionsMATLAB: Plot of theta_new and cos theta After the first plot(theta_new,cos(theta_new),'*')add hold onand remove the second plot() call. MATLAB: Solving non linear equation using fsolve 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 Related QuestionDifferentiate with respect to ‘cos(theta)’How to define a function that evaluates in input
Best Answer