Error using Bar, X must be same Length as Y.
Mostrar comentarios más antiguos
I am trying to plot on a bar chart through app designer and i'm getting the following error: Error using bar (line 172)
X must be same length as Y.
My code is as below:
bar(app.UIAxesPositionBar, T_BarChart.UndlyDate, T_BarChart{:,{'TotalPosition'}}, 0.8,'FaceAlpha',0.5);
hold(app.UIAxesPositionBar,'on');
bar(app.UIAxesPositionBar, T_BarChart.UndlyDate, T_BarChart{:,{'FuturesPosition','DeltaEquivPosition'}}, 0.8,'FaceAlpha', 0.5);
The second call to bar throws the error, when i inspect the table i'm using you can see its 1x4, the first call to bar works just fine.
You can see the table contents/variables below:
K>> bar(app.UIAxesPositionBar, T_BarChart.UndlyDate, T_BarChart{:,{'FuturesPosition','DeltaEquivPosition'}}, 0.8,'FaceAlpha', 0.5);
Error using bar (line 172)
X must be same length as Y.
K>> T_BarChart.UndlyDate
ans =
datetime
01-Dec-2019
K>> T_BarChart{:,{'FuturesPosition','DeltaEquivPosition'}}
ans =
1.0e+02 *
0 -1.887165000000000
K>> T_BarChart
T_BarChart =
1×4 table
UndlyDate FuturesPosition DeltaEquivPosition TotalPosition
___________ _______________ __________________ _____________
01-Dec-2019 0 -188.7165 -188.7165
Any ideas on why i am getting the "must be the same length" error?
4 comentarios
Nyaz Jamel
el 25 de Mayo de 2020
1500
Error using stem (line 43)
X must be same length as Y.
Error in untitled4 (line 6) stem(n,x) Please help My common:
n=input('input length of the sine seq'); L= input('up sampling factor'); fi= input('input signal freq'); t=0:n-1; x=sin(2*pi*fi*t); y=zeros(1,L*length(x)); y=x([1:L:length(x)]); subplot(2,1,1); stem(n,x) title('input sequence'); xlabel('time'); ylabel('amplitude'); subplot(2,1,2); stem(n,y(1:length(x))) title(['output sequence',num2str(L)]); xlabel('time'); ylabel('amplitude');
Nyaz Jamel
el 25 de Mayo de 2020
Help me bro
Nyaz Jamel
el 25 de Mayo de 2020
Note : Sample value=50, upsampling=2 input signal freq=1500
Adam Danz
el 25 de Mayo de 2020
With
stem(app.UIAxes, X, Y)
length(X) must equal length(Y). According to your error message, this is not the case for your values. It makes sense, right? X and Y are pairs of values so each X needs to have a Y value and vise versa.
Respuesta aceptada
Más respuestas (2)
Matt Glowacki
el 24 de Jun. de 2019
1 comentario
Adam Danz
el 25 de Jun. de 2019
Please reply in the comment section under my answer.
Matt Glowacki
el 25 de Jun. de 2019
1 comentario
Adam Danz
el 25 de Jun. de 2019
Please reply in the comment section under my answer.
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!