Error constructing shaded error bar

5 ビュー (過去 30 日間)
Samuele Bolotta
Samuele Bolotta 2020 年 5 月 3 日
回答済み: Ananya Tewari 2020 年 6 月 19 日
This is what I'm trying to do. X is a vector that goes from 1 to 5121; y is a nx5121 vector (where n varies between 1 and some other small number, depending on the number of data contained); as for errBar, I'm not sure. This is what the previous person at the lab wrote, but it's not working.
if size(wholedff{i}) >= 1
figure;
hold on
shadedErrorBar(1:5121, wholedff{i}',nanstd(wholedff{i}')/sqrt(length(wholedff{i}(1,:))))
ylabel('dF/F')
xticks([0:Epoch_length:Epoch_length*4])
xticklabels({'-10','0','10'})
xlabel('seconds')
This is the error that I get:
Error using plot
Vectors must be the same length.
Error in shadedErrorBar>makePlot (line 162)
H.mainLine=plot(x,y,lineProps{:});
Error in shadedErrorBar (line 138)
H = makePlot(x,y,errBar,lineProps,transparent,patchSaturation);
Error in StimulusTestNew (line 133)
shadedErrorBar(1:5121, wholedff{i}',nanstd(wholedff{i}')/sqrt(length(wholedff{i}(1,:))))
This is the documentation of the function:
Inputs (required)
% x - vector of x values [optional, can be left empty]
% y - vector of y values or a matrix of n observations by m cases
% where m has length(x);
% errBar - if a vector we draw symmetric errorbars. If it has a size
% of [2,length(x)] then we draw asymmetric error bars with
% row 1 being the upper bar and row 2 being the lower bar
% (with respect to y -- see demo). ** alternatively **
% errBar can be a cellArray of two function handles. The
% first defines statistic the line should be and the second
% defines the error bar.
Thanks for the help!

回答 (1 件)

Ananya Tewari
Ananya Tewari 2020 年 6 月 19 日
Hi Samuele,
As I understand while executing your code you are facing errors.
According to error shown, the inputs to plot() function must be of same length but in the call to plot the X,Y does not seem to be of same length.
This can be verified by the documentation you provided
% x - vector of x values [optional, can be left empty]
% y - vector of y values or a matrix of n observations by m cases
% where m has length(x);
Before plotting you can verify whether X is empty or not and if empty you can initialize it as per your need.
Follow the link below for further understanding of plot()

カテゴリ

Help Center および File ExchangeErrorbars についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by