Why can't I enter any number that is not a one digit number on my UITable?
1 回表示 (過去 30 日間)
古いコメントを表示
Giulia Di Giorgio
2023 年 3 月 12 日
コメント済み: Giulia Di Giorgio
2023 年 3 月 12 日
Hello, I'm trying to get a column vector from a matrix I withdraw from an UITable. It works perfectly with one digit numbers (ex. 1 2 3 4 ...9) but when I enter 2 or more digit numbers it shows this error: Dimensions of arrays being concatenated are not consistent. For example, this data:

%Obtener los datos de la tabla
tabla=app.UITable.Data;
M=cell2mat(tabla)
%Obtener las columnas de la tabla
h=M(:,1)
tP=M(:,2)
tT=M(:,3)
%Convertir cada columna a vector columna
vh=str2num(reshape(h,[],1))
vtP=str2num(reshape(tP,[],1))
vtT=str2num(reshape(tT,[],1))
1 件のコメント
Walter Roberson
2023 年 3 月 12 日
Note that
h=M(:,1)
and similar lines can only return a (possibly empty) column vector.
vh=str2num(reshape(h,[],1))
and the reshape(h,[],1) can only reshape something into a (possibly empty) column vector before calling str2num. But it is already certain to be a column vector, so the reshape() is unnecessary code.
採用された回答
Walter Roberson
2023 年 3 月 12 日
If your uitable contained numeric entries, then the 1 and the 15 in h would be right aligned, like
1
15
but they are left aligned in your image, like
1
15
Therefore your entries are text not numeric. And of course for text, the number of characters in each matters.
You do not show it here, but in your previous questions you have been shown initializing row entries to {'','',''} which are text entries not numeric.
And no, you cannot have blank numeric entries. If you want to switch to numeric entries you should initialize the row to 0, 0, 0
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!