How to plot general solution of a trigonometric function???

I want to plot a graph of a and b defined by this equation. 1-2*cosd(a)+2*cosd(b)=0 when I started plotting only graph of the principal solutions of cos is considered. whereas i want all possibilities of general solutions. by using contour only plot of functions can be drawn. what do i do now????

8 件のコメント

HARSHA GYANANI
HARSHA GYANANI 2018 年 6 月 11 日
編集済み: Walter Roberson 2018 年 6 月 11 日
x=0:1:90
y=(acosd((-1+2*cosd(5*x))/2))/5;
plot(x,y)
this is coming as
but i want this to be as
how can it be done???
Walter Roberson
Walter Roberson 2018 年 6 月 11 日
The straight line is not present in the plot unless you ignore the imaginary component of y.
What would be the equation for the other parts you want drawn? Those curves are not the half circles.
HARSHA GYANANI
HARSHA GYANANI 2018 年 6 月 12 日
equation is same as matlab only follows principal solution but i want graphs for general solution. when i manually plotted by considering all the solution that comes out to be as 2nd graph.for eg. acosd(0)=90,270 and so on i want to get all possibiliities
Walter Roberson
Walter Roberson 2018 年 6 月 12 日
Why stop at two solutions? Why not also look at 450, 630, and so on?
HARSHA GYANANI
HARSHA GYANANI 2018 年 6 月 13 日
I want to look at more but when problem occured i had to stop. Please do help me in this...
Walter Roberson
Walter Roberson 2018 年 6 月 13 日
The below code requires R2016b or later:
Macosd = @(X) sort([(-1800:360:1800).'+acosd(X); (-1800:360:1800).'-acosd(X)]);
x = linspace(0, 90, 361);
y = (Macosd((-1+2*cosd(5*x))/2))./5;
plot(x, real(y))
If you zoom into the region near x = 24, you might see what looks like a "bounce". This is a side effect of the fact that when you start talking about taking multiple non-principle branches of the acosd, that the ordering of the branches is not well defined. Also, the sorting is not well defined for the places where acosd is imaginary. Also, as a limitation, the Macosd function produces duplicate points for cosd = +/- 1, but that case cannot show up in this particular use of it.
For release before R2016b, the code could be rewritten to use bsxfun.
HARSHA GYANANI
HARSHA GYANANI 2018 年 6 月 17 日
I am using 2015,,,, can u please send me code of 2015a as i dont know how to convert this using bsxfun
Walter Roberson
Walter Roberson 2018 年 6 月 17 日
Macosd = @(X) sort([ bsxfun(@plus, (-1800:360:1800).', acosd(X)); bsxfun(@minus, (-1800:360:1800).', acosd(X))]);

サインインしてコメントする。

回答 (2 件)

KSSV
KSSV 2018 年 4 月 11 日

2 投票

N = 100 ;
a = linspace(0,2*pi,N) ;
b = linspace(0,2*pi,N) ;
[X,Y] = meshgrid(a,b) ;
Z = 1-2*cos(X)+2*cos(Y) ;
surf(X,Y,Z)
hold on
contour(X,Y,Z,[0 0],'r')

5 件のコメント

HARSHA GYANANI
HARSHA GYANANI 2018 年 4 月 13 日
Thanku sir, but i want a 2D plot on X and Y axis.
KSSV
KSSV 2018 年 4 月 13 日
contour(X,Y,Z,[0 0],'r')
HARSHA GYANANI
HARSHA GYANANI 2018 年 4 月 13 日
this command is giving a 3D plot.
Vivek Kumar
Vivek Kumar 2020 年 3 月 21 日
bro please help me to plot a graph delta_lambda=h(1-cosX)/cm please help me
Walter Roberson
Walter Roberson 2020 年 3 月 21 日
Vivek Kumar: you should open a new Question for that. In that Question, please indicate which variables are your independent variables, and what range of values you want, and what style of plot you want.

サインインしてコメントする。

Torsten
Torsten 2018 年 4 月 13 日

0 投票

Derive b as a function of a, prescribe a range for a, calculate b and use "plot(a,b)".
Best wishes
Torsten.

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2018 年 4 月 11 日

コメント済み:

2020 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by