Why can't I enter any number that is not a one digit number on my UITable?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Giulia Di Giorgio
el 12 de Mzo. de 2023
Comentada: Giulia Di Giorgio
el 12 de Mzo. de 2023
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 comentario
Walter Roberson
el 12 de Mzo. de 2023
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.
Respuesta aceptada
Walter Roberson
el 12 de Mzo. de 2023
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!