plotting a mean response curve

4 ビュー (過去 30 日間)
Jason
Jason 2017 年 7 月 18 日
コメント済み: Star Strider 2017 年 7 月 20 日
Apologies - I am a Matlab newbie and have spent a few hours looking for online help with this. All I want to be able to do is to pull in (or generate) numerous "dose-response" datasets (each one a pair of vectors, one "x", the other "R" (the response). The x vector is common to all. I want to: 1. Plot all curves 2. Plot the mean response curve 3. Show standard deviations at each x point
I have tried:
x=[0, 50, 200, 500]
R1=[10, 30, 90, 200];
R2=[10, 15, 60, 90];
R3=[1, 5, 40, 75];
Rave = mean([R1 R2 R3],2); % assuming Ys are column vectors and defines mean of the response vectors
plot(x,R1,'b')
hold on
plot(x,R2,'b')
hold on
plot(x,R3,'b')
plot(x, Rave,'-s','MarkerSize',5,'MarkerEdgeColor','red','MarkerFaceColor',[1 .6 .6]) %// mean of all blue curves) %plots the 3 vectors in blue
This is not working (in the sense that the means are not right). I am sure this is simple so apologies in advance but any help hugely welcome

採用された回答

Star Strider
Star Strider 2017 年 7 月 18 日
‘assuming Ys are column vectors and defines mean of the response vectors’
They are not, at least in the code that you posted. If you want them as column vectors, use semicolons ‘;’ that will concatenate the elements of the vectors vertically instead of commas ‘,’ that will concatenate them horizontally.
This is probably what you want:
x=[0, 50, 200, 500]
R1=[10; 30; 90; 200];
R2=[10; 15; 60; 90];
R3=[1; 5; 40; 75];
Rave = mean([R1 R2 R3],2);
figure(1)
plot(x,R1,'b')
hold on
plot(x,R2,'b')
hold on
plot(x,R3,'b')
plot(x, Rave,'-sr','MarkerSize',5,'MarkerEdgeColor','red','MarkerFaceColor',[1 .6 .6]) %// mean of all blue curves) %plots the 3 vectors in blue
The other change I made was to plot the line for the mean entirely in red to make it easier to see.
  10 件のコメント
Jason
Jason 2017 年 7 月 20 日
You are an absolute star - thank you very much.
Star Strider
Star Strider 2017 年 7 月 20 日
Thank you! As always, my pleasure.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by