필터 지우기
필터 지우기

plot values of same index from two vectors

조회 수: 2 (최근 30일)
Nona
Nona 2021년 6월 14일
댓글: Nona 2021년 6월 14일
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
Megumi Fukuda
Megumi Fukuda 2021년 6월 14일
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)?

댓글을 달려면 로그인하십시오.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 14일
편집: Scott MacKenzie 2021년 6월 14일
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' ''};

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by