How to find the slope of phase data (between two points) which is uneven

3 ビュー (過去 30 日間)
Sriram Guddati
Sriram Guddati 2018 年 10 月 12 日
回答済み: Greg Dionne 2018 年 10 月 26 日
I have a phase vs frequency plot. I need to find the slope between point 'a' and point 'b' in an automated way instead of looking at the points 'a' and 'b' and calculating the slope. Can anyone help me with this?

採用された回答

Image Analyst
Image Analyst 2018 年 10 月 12 日
You ask ONLY about the slope, not about finding a and b, so I assume you've found "a" and "b" already. So, assuming your "a" is index1 and "b" is index2, you can do this
coefficients = polyfit(x(index1):x(index2), signal(index1:index2), 1);
slope = coefficients(1);
  3 件のコメント
Image Analyst
Image Analyst 2018 年 10 月 12 日
OK, that wasn't stated in the original question. So you can use
[peakValues, indexOfPeaks] = findpeaks(signal);
[valleyValues, indexOfValleys] = findpeaks(-signal);
valleyValues = -valleyValues; % Flip again to get right side up.
Of course you will find lots of peaks and lots of valleys so you'll have to decide which to concentrate on.
Sriram Guddati
Sriram Guddati 2018 年 10 月 12 日
Thank you, I will try this.

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

その他の回答 (2 件)

jonas
jonas 2018 年 10 月 12 日
編集済み: jonas 2018 年 10 月 12 日
I would suggest using either findpeaks to determine points a and b and then calculate the average slope or alternatively using findchangepts. If you want code, then I suggest you upload some data.
  3 件のコメント
jonas
jonas 2018 年 10 月 12 日
Yes of course. The index is the second output of findpeaks. Note that you need to run the function two times, one for peaks and one for valleys. For the latter, you just turn the plot upside down, i.e.
findpeaks(-y)
Sriram Guddati
Sriram Guddati 2018 年 10 月 12 日
Thanks, I will try this method

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


Greg Dionne
Greg Dionne 2018 年 10 月 26 日
You could try a combination of unwrap (to remove the jumps of your array) and sgolay to do the differentiation. See the second example on how to perform differentiation.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by