Change Line width and Line color in findchangepts function.

34 ビュー (過去 30 日間)
Ron
Ron 2024 年 11 月 13 日 20:14
コメント済み: Voss 2024 年 11 月 19 日 20:17
I have a dataset, attached, and I am using findchangepts function to partition the data in different number of regions. I wish to control the line widht and other properties of the graph like Line style and color but I am not able to do so. Can anyone please help me with this? Thanking you in advance. My data looks like this.
  1 件のコメント
Ron
Ron 2024 年 11 月 13 日 20:17
I did forget to add the code I am using. This is my code.
findchangepts(ACc(:,2),'Statistic','mean','MaxNumChanges',2); hold on

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

採用された回答

Voss
Voss 2024 年 11 月 13 日 21:08
編集済み: Voss 2024 年 11 月 13 日 21:10
As I interpret the question, you want to plot the data in different regions with different line properties. If that's the case, try something like this:
ACc = readmatrix('AC_1Hzcsv.csv');
idx = findchangepts(ACc(:,2),'Statistic','mean','MaxNumChanges',3)
idx = 3×1
191 194 1547
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
ylim([0 1])
hold on
line_widths = [2, 3, 1, 2];
line_styles = {'-', '--', ':', '-.'};
line_colors = 'rgbk';
N = size(ACc,1);
x = (1:N)/5; % /5 to match your x-scale?
idx = [1; idx; N]
idx = 5×1
1 191 194 1547 4501
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
for ii = 1:numel(idx)-1
tmp = idx(ii):idx(ii+1);
plot(x(tmp),ACc(tmp,2), ...
'LineWidth',line_widths(ii), ...
'LineStyle',line_styles{ii}, ...
'Color',line_colors(ii));
end
  2 件のコメント
Ron
Ron 2024 年 11 月 14 日 8:41
Sir thank you so much for taking out time to help me solving this issue. I will run the code and will let you know about the status soon.
Voss
Voss 2024 年 11 月 19 日 20:17
You're welcome!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 11 月 13 日 20:55
After you
findchangepts(ACc(:,2),'Statistic','mean','MaxNumChanges',2);
then do
ax = gca;
%if you want to affect the line holding the original data
ax.Children(2).LineWidth = APPROPRIATE_LINE_WIDTH;
ax.Children(2).LineStyle = APPROPRIATE_LINE_STYLE;
ax.Children(2).Color = APPROPRIATE_COLOR;
%if you want to affect the lines showing the breaks in regions
ax.Children(1).LineWidth = APPROPRIATE_LINE_WIDTH;
ax.Children(1).LineStyle = APPROPRIATE_LINE_STYLE;
ax.Children(1).Color = APPROPRIATE_COLOR;
  1 件のコメント
Ron
Ron 2024 年 11 月 14 日 8:41
Sir thank you so much for taking out time to help me solving this issue. I will run the code and will let you know about the status soon.

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

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by