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 1×4, 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?
Best Answer