hi everyone, i have 2 column such as
X=[ -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10]
Y=[0.9996 1.0000 0.9772 0.8978 0.6916 0.3253 0.0680 0.0091 0.0089 0.0088 0.0098 0.0119]
i want to plot SEM error bars using errorbar function,but when i calculate the SEM it only gives me one value and errobar function show this error:
'X, Y and error bars must all be the same length'
can you please help me with that.
SEM=std(data)./sqrt(length(data))
thank you

 채택된 답변

Star Strider
Star Strider 2017년 6월 10일

0 개 추천

If your ‘data’ matrix variables are in columns and ‘Y’ is the mean, you need to calculate the ‘SEM’ across the columns of ‘data’:
SEM = std(data,2)./sqrt(size(data,2));
You calculate the mean the same way:
Y = mean(data,2);
Note: This is a guess, since I do not have your data.

댓글 수: 4

best16 programmer
best16 programmer 2017년 6월 10일
thank you for the answer my data column is
data=[-79.6696 -73.4101 -80.6085 -72.3433 -70.2953 -77.0140 -75.6808 -75.9423]
Star Strider
Star Strider 2017년 6월 10일
My pleasure.
Your ‘data’ vector has only 8 elements. Your other vectors have 12. Your ‘data’ vector will produce only 1 value if you calculate the standard deviation over the column, and the standard deviation is 0 for single values (calculating the standard deviation row-wise, across the columns).
There is no solution to your problem with the information you have provided.
best16 programmer
best16 programmer 2017년 6월 10일
thank you again,can you please show me some example for this type of operation
My pleasure.
This is one example (using your ‘X’ and ‘Y’ vectors):
X = [ -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10]';
Y = [0.9996 1.0000 0.9772 0.8978 0.6916 0.3253 0.0680 0.0091 0.0089 0.0088 0.0098 0.0119]';
data = Y + 0.1*randn(12, 8); % Create (12x8) Data Array
data_mean = mean(data,2); % Mean Across Columns
data_SEM = std(data,[],2)/sqrt(size(data,2)); % SEM Across Columns
figure(1)
errorbar(X, data_mean, data_SEM)
grid
axis([-130 0 ylim])

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Errorbars에 대해 자세히 알아보기

제품

질문:

2017년 6월 10일

댓글:

2017년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by