Plot graphic with 3 variables

7 Ansichten (letzte 30 Tage)
Happy Bear
Happy Bear am 16 Mär. 2020
Kommentiert: Ameer Hamza am 17 Mär. 2020
Hello everyone,
I want to plot a graphic with my data that is grouped by categories: level (0.03, 0.05 or 0.08) and 1/0 (category 1 or 0).
I want to plot time as a function of level (3 levels), split by category 1 and category 0, as shown in the drawing that i sketched.
How can I do it in matlab?

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 16 Mär. 2020
Bearbeitet: Ameer Hamza am 16 Mär. 2020
Following code shows the example to extract data and plot in on the axes
A = [1 0.03 0.51;
1 0.05 0.42;
1 0.08 0.45;
0 0.03 0.57;
0 0.05 0.47;
0 0.08 0.60];
split_matrix = splitapply(@(x) {x}, A(:,2:3), A(:,1)+1);
ax = axes();
hold(ax);
for i=1:numel(split_matrix)
plot(ax, split_matrix{i}(:,1), split_matrix{i}(:,2), '.-', 'MarkerSize', 50, 'LineWidth', 2)
end
xlabel('Level');
ylabel('Time (s)');
xlim([0.03 0.08])
ylim([0.2 0.6]);
  2 Kommentare
Happy Bear
Happy Bear am 17 Mär. 2020
Exactly what I wanted, thank you!
Just replaced xlim with xticks([0.03 0.05 0.08]).
Ameer Hamza
Ameer Hamza am 17 Mär. 2020
Glad to be of help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots 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!

Translated by