Error using Bar, X must be same Length as Y.
이전 댓글 표시
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
Nyaz Jamel
2020년 5월 25일
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
2020년 5월 25일
Help me bro
Nyaz Jamel
2020년 5월 25일
Note : Sample value=50, upsampling=2 input signal freq=1500
Adam Danz
2020년 5월 25일
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.
채택된 답변
추가 답변 (2개)
Matt Glowacki
2019년 6월 24일
댓글 수: 1
Adam Danz
2019년 6월 25일
Please reply in the comment section under my answer.
Matt Glowacki
2019년 6월 25일
댓글 수: 1
Adam Danz
2019년 6월 25일
Please reply in the comment section under my answer.
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!