Azzera filtri
Azzera filtri

plot values of same index from two vectors

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Megumi Fukuda
Megumi Fukuda il 14 Giu 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)?

Accedi per commentare.

Risposta accettata

Scott MacKenzie
Scott MacKenzie il 14 Giu 2021
Modificato: Scott MacKenzie il 14 Giu 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' ''};

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by