How can I parametrize a cosine to become asymmetric?

4 ビュー (過去 30 日間)
lzeeysjp
lzeeysjp 2017 年 5 月 30 日
コメント済み: lzeeysjp 2017 年 5 月 30 日
Hello,
I have a question and hope that you can help me.
I need function that looks like an cosine, but with the turning points at different places. They should shifted towards 0 and 2pi (see image below) depending on some parameter. Ideally the function converges to the cosine for some value.
And no, its no homework :) I need the function for an optimization problem I am trying to solve.
Kind regards, Joe
  2 件のコメント
Jan
Jan 2017 年 5 月 30 日
編集済み: Jan 2017 年 5 月 30 日
There is an infinite number of such functions. Do you have any further limitations? The shown curve is still symmetric. Do you mean a symmetry realted to the rotation around the y=0 points?
lzeeysjp
lzeeysjp 2017 年 5 月 30 日
編集済み: lzeeysjp 2017 年 5 月 30 日
No limitation so far. Built-in would be great :)
I meant symmetric at x = Pi when using fliplr.
One possibility I found so far is
  • add an offset to the cosine (to stay positive)
  • (cos(x) + 2.0)^n, where n is the free parameter
  • then map the result to [-1, 1]

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

採用された回答

Stephen23
Stephen23 2017 年 5 月 30 日
編集済み: Stephen23 2017 年 5 月 30 日
This is one simple solution, where a p value of 1 returns cos, and other p values change the shape:
fun = @(x,p)2*(((1+cos(x))/2).^p)-1;
X = 0:0.01:2*pi;
Y1 = fun(X,1); % cos
Y2 = fun(X,3); % adjusted
plot(X,Y1,X,Y2)
  1 件のコメント
lzeeysjp
lzeeysjp 2017 年 5 月 30 日
Yes that works, too. I guess this is similar to the one I posted in the comment above. By adding +2.0 to the cosine it also seems to work for negative parameters.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by