필터 지우기
필터 지우기

How to Help Determine the Roots of X =Tan(X), Graph Y = X And Y = Tan(X), And also plot a red circle At The Intersection Points Of The Two Curves. Please help.

조회 수: 4 (최근 30일)
clear all
close all
clc
% %%To plot tan(theta), if you use usual plot function
% and linspace, you get a cntinuous function like this
% to use fplot, you have to initiate function
%%y=tan(x) function theta in radians=180 deg/Pi
f=@(theta) tan(theta) %@(theta) mean f is a function on theta
%%y=tan(x) function theta in degrees
%f2=@(theta) tand(theta); % tand(theta) theta is in degree
%%y=x straight line function theta in radians=180 deg/Pi
f3=@(theta) theta; %straight line y=x
%Plot the functions
figure
fplot(f,[-2*pi,2*pi]);
% figure
% fplot(f2,[-360,360]);
hold on
fplot(f3,f3)
ylim([0 6])
xlim([0 6])
%Note fplot have the same syntax as ezplot
%%FIND x VALUE IN THE FOLLOWING ITERATION%%%
tanxx = @(x) tan(x)-x
for a = 4:4.6
xs = fzero(tanxx, a)
end
  댓글 수: 2
Steven Lord
Steven Lord 2023년 5월 17일
What does "could not make it work" mean in this context?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
juan sanchez
juan sanchez 2023년 5월 18일
I meant that the 'intersections' function did not worked for my posted code. I wanted to know how to make this function 'intersections' work and then be able to plot the roots as red circle markers on the plot.

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

채택된 답변

Nikhil Baishkiyar
Nikhil Baishkiyar 2023년 6월 23일
편집: Nikhil Baishkiyar 2023년 6월 24일
Have you seen the example given for the function intersections? It computes the intersection of two vectors, not two function handles. I have tried it and found the solution. You can use
x = 0:0.0001:5;
f = tan(x);
f3 = x;
I used these vectors in the same way as this example and got what you wanted.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by