Effacer les filtres
Effacer les filtres

plot values of same index from two vectors

2 vues (au cours des 30 derniers jours)
Nona
Nona le 14 Juin 2021
Commenté : Nona le 14 Juin 2021
I have three vectors with the same amount of elements (pre values and post values of all participants, respectively and control data)
I would like to create a plot of the individual change, so x-axis = pre, post, control, y-axis = value of vector index and then plot the first index of the vector pre together with the first index of the vector post and so on while control data is seperate in the third 'column'. I can't figure out how to do this.
It should look something like this at the end.
  1 commentaire
Megumi Fukuda
Megumi Fukuda le 14 Juin 2021
Can you clarify the struture of your data and what you want to do? I assume you have three vectors (v_pre, v_post, and v_cont) without any missing data, and v_pre(1), v_post(1), and v_cont(1) is the pre data of participant1. What do you mean by "while control data is seperate in the third 'column'"? Is it graphical representation of the graph (i.e. no lines between v_post and v_cont)?

Connectez-vous pour commenter.

Réponse acceptée

Scott MacKenzie
Scott MacKenzie le 14 Juin 2021
Modifié(e) : Scott MacKenzie le 14 Juin 2021
Here's what I put together. It looks a bit crazy because the data are just random numbers. But, I think it achieves more or less what you are after, given your example plot.
n = 8; % number of participants
x = 4; % number of data points: pre1, pre2, post1, post1
% test data (replace with your data)
data = rand(x,n) * 100;
control = rand(1,n) * 100;
plot(1:x, data, '-o');
hold on;
plot(x+1, control, 'ok', 'markerfacecolor', [.4 .4 .4]);
ax = gca;
ax.XLim = [0 6];
ax.YLim = [0 120];
ax.XLabel.String = 'Condition';
ax.XTickLabel = { '' '1Pre' '2Pre' '1Post' '2Post' 'Control' ''};

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by