Error using Bar, X must be same Length as Y.
Mostra commenti meno recenti
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 Commenti
Nyaz Jamel
il 25 Mag 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
il 25 Mag 2020
Help me bro
Nyaz Jamel
il 25 Mag 2020
Note : Sample value=50, upsampling=2 input signal freq=1500
Adam Danz
il 25 Mag 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.
Risposta accettata
Più risposte (2)
Matt Glowacki
il 24 Giu 2019
1 Commento
Adam Danz
il 25 Giu 2019
Please reply in the comment section under my answer.
Matt Glowacki
il 25 Giu 2019
1 Commento
Adam Danz
il 25 Giu 2019
Please reply in the comment section under my answer.
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!