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!