Displaying timing of activation on a graph

2 visualizzazioni (ultimi 30 giorni)
Hi Guys,
I want to create a figure like the one attached. I have the starting and end points for when each muscle is activated for instance the bicep maybe be activated between (10-30%) and then (50-70%) of the propulsion cycle but I'm struggling to display this on a graph.
If anyone can help it would be much appreciated.
Thanks!

Risposta accettata

Ayush
Ayush il 23 Set 2024
Hi Renee
Here is the sample code that you can use to create the horizonal lines as you described in the attached figure:
% Define the data for each tissue type
% Format: [start_x, end_x, y_position]
tissue_data = [
0, 20, 1; % Tissue 1, Line 1
30, 40, 1; % Tissue 1, Line 2
80, 100, 1; % Tissue 1, Line 3
50, 60, 2; % Tissue 2, Line 1
70, 90, 2; % Tissue 2, Line 2
10, 30, 3; % Tissue 3, Line 1
40, 60, 3; % Tissue 3, Line 2
70, 80, 4; % Tissue 4, Line 1
85, 100, 4; % Tissue 4, Line 2
% Add more lines here as needed
];
% Create a figure
figure;
hold on;
% Loop through each row in the tissue_data
for i = 1:size(tissue_data, 1)
% Extract start and end points and the y-position for the tissue line
start_x = tissue_data(i, 1);
end_x = tissue_data(i, 2);
y_position = tissue_data(i, 3);
% Plot the horizontal line
plot([start_x, end_x], [y_position, y_position], 'LineWidth', 2);
end
% Customize the axes
xlabel('% Propulsion Cycle');
ylabel('Tissue Type');
yticks(1:4);
yticklabels({'Tissue 1', 'Tissue 2', 'Tissue 3', 'Tissue 4'});
xlim([0, 100]);
ylim([0.5, 4.5]);
% Add grid for better visualization
grid on;
% Add title
title('Tissue Activation Across Propulsion Cycle');
% Hold off to finish plotting
hold off;
I hope it helps!

Più risposte (1)

Renee Wurfel
Renee Wurfel il 26 Set 2024
Thank you very much for your reply's it is much appreciated, both of your codes worked I just accepted the top one as they were the first to post. Again thank you very much appreciated.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by