For loop for different step size
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear Matlab Community,
I have a matrix like
[24 80; 24 80; 24 80; 24 80; 30 120; 30 120; 48 124; 48 124; 48 124]
I need to have a plot that 80, 120, 124 be in the x axis and the numbers 4,2,3 be in the y axis.
We have 4 of 24, 3 of 30 and 3 of 48.
Thanks :)))
0 Kommentare
Akzeptierte Antwort
Voss
am 3 Okt. 2024
M = [24 80; 24 80; 24 80; 24 80; 30 120; 30 120; 48 124; 48 124; 48 124];
[c,g] = groupcounts(M(:,2))
There are your y- and x-axis numbers.
Perhaps one of these plots is what you mean:
x = 1:numel(g);
figure('Position',[10 10 1000 400])
tiledlayout(2,2)
nexttile
plot(g,c)
nexttile
bar(g,c)
nexttile
plot(x,c)
xticks(x)
xticklabels(g)
nexttile
bar(x,c)
xticks(x)
xticklabels(g)
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!