Effacer les filtres
Effacer les filtres

How to set Categories consistent when using "signalMask" and "plotsigroi" ?

27 vues (au cours des 30 derniers jours)
Mibang
Mibang le 7 Mar 2024
Réponse apportée : Drishti le 12 Août 2024 à 7:59
I want to plot using the code below with the loaded mat file attached.
For example, when "m1=200" I obtain the attached figure.
But, the issue is that, the cetegories are not the same order between two subplots.
I want the categories being the same order, e.g., "n/a", "N", "V", "A" in both subplots.
I would appreciate it if you could help me how to do it.
Thank you,
%%
load qNa.mat
m1=200;
figure;
M = signalMask(tl{m1}); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
ls = p1.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ',m1);
title(srt)
M = signalMask(pl{m1}); subplot(2,1,2);
p2 = plotsigroi(M,G2{m1});
ls = p2.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt2 = sprintf('N only w/Est, data-%d',m1);
title(srt2)
  1 commentaire
Mibang
Mibang le 7 Mar 2024
Modifié(e) : Mibang le 7 Mar 2024
I got an answer from a staff memeber of MathWorks as below to share:
...
C = reordercats(tl{m1}, ["n/a", "A", "N", "V"])
M = signalMask(C); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
...

Connectez-vous pour commenter.

Réponses (1)

Drishti
Drishti le 12 Août 2024 à 7:59
Hi Mibang,
I understand that you are encountering an issue with setting the categories of the subplot while using the functions ‘signalMask’ and ‘plotsigroi’ in MATLAB R2023b.
To address this, you can use the ‘reordercats’ function. This function is useful when you need to specify a custom order for the categories.
Furthermore, refer to the example code provided below
% Reorder categories for the first subplot
C = reordercats(tl{m1}, ["n/a", "N", "V", "A"]); %custom order for categories
M = signalMask(C);
subplot(2,1,1);
p1 = plotsigroi(M, G2{m1});
ls = p1.Children;
for i2 = 1:size(ls, 1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ', m1);
title(srt);
For more information, you can refer to the MATLAB Documentation of the ‘reordercats’ function.
I hope this helps.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by