Error constructing shaded error bar

4 visualizaciones (últimos 30 días)
Samuele Bolotta
Samuele Bolotta el 3 de Mayo de 2020
Respondida: Ananya Tewari el 19 de Jun. de 2020
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!

Respuestas (1)

Ananya Tewari
Ananya Tewari el 19 de Jun. de 2020
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()

Categorías

Más información sobre Errorbars en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by