how to determine each local min point?

1 回表示 (過去 30 日間)
William
William 2013 年 3 月 6 日
Hi everyone, I have a urgent question to seek for help...
I have a sine wave however, angle in the sine wave is not a constant variation of x as shown below...
x = 0: 0.00001: 4;
v = x.*exp(x/2);
t = sin(v);
plot(x,t);
My trouble is how to display each of the local xmin point?
From the plot itself i wanted to display xmin1 = 1.859, xmin2 = 2.73, and xmin3 = 3.307.
Hope to hear from anyone soon... been cracking my head for the past weeks... )':
Best Regards
Will*

採用された回答

Image Analyst
Image Analyst 2013 年 3 月 6 日
編集済み: Image Analyst 2013 年 3 月 6 日
If you have the Image Processing Toolbox, you can use imregionalmin(), like this:
% Original code
x = 0: 0.00001: 4;
v = x.*exp(x/2);
t = sin(v);
plot(x,t);
% Image Analyst's code:
minsIndexes = imregionalmin(t); % Logical array of where mins are.
% Extract the t values at those min locations;
minValues = t(minsIndexes)
% Get the x values at those mins.
minX = x(minsIndexes)
% Plot star over the mins.
hold on;
plot(minX, minValues, 'r*', 'MarkerSize', 10);
In the command window:
minValues =
0 -1.00 -1.00 -1.00 -1.00 -0.96
minX =
0 1.86 2.76 3.31 3.70 4.00
  1 件のコメント
William
William 2013 年 3 月 7 日
Thanks a lot and it did solve my troubles!!! :)

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

その他の回答 (1 件)

Matt J
Matt J 2013 年 3 月 6 日
編集済み: Matt J 2013 年 3 月 6 日
k=3; %Do this for all desired k>=0
xmin=fzero(@(x) x.*exp(x/2) - 2*pi*k,0)
  1 件のコメント
Matt J
Matt J 2013 年 3 月 6 日
There is also a minimum at x=-2, as elementary calculus can tell you.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by