Table not structuring the way I want
Mostrar comentarios más antiguos
I want to input information so that it creates a x by 7 table, where x depends on the number inputed at the beginning. However, it keeps creating a 1 by 7 table but in the table each column has x number of values instead of moving down to the next row for each value. I've tried to change things but I also get a "Conversion to double from cell is not possible" error when I swap my variables to () instead of {} so I'm stuck.
answerTotalNoSpaces=inputdlg('Enter','Total Number Of Spaces');
totalNoSpaces=str2double(answerTotalNoSpaces{1});
SpaceType=(totalNoSpaces);
FloorNumber=(totalNoSpaces);
SpaceX=(totalNoSpaces);
SpaceY=(totalNoSpaces);
SpaceZ=(totalNoSpaces);
SpaceCoordX=(totalNoSpaces);
SpaceCoordY=(totalNoSpaces);
for i=1:1:totalNoSpaces
list={'Residential','Office','Education','Toilet','Storage'};
[selectionindex,ok]=listdlg('ListString',list);
if ok
SpaceType(i)=list(selectionindex);
end
answerFloorNumber=inputdlg('Enter','Floor Number');
FloorNumber(i)=str2double(answerFloorNumber{1});
answerSpaceX=inputdlg('Enter','Space X distance (m)');
SpaceX(i)=str2double(answerSpaceX{1});
answerSpaceY=inputdlg('Enter','Space Y distance (m)');
SpaceY(i)=str2double(answerSpaceY{1});
answerSpaceZ=inputdlg('Enter','Space Z distance (m)');
SpaceZ(i)=str2double(answerSpaceZ{1});
answerCoordX=inputdlg('Enter','Space X coord');
SpaceCoordX(i)=str2double(answerCoordX{1});
answerCoordY=inputdlg('Enter','Space Y coord');
SpaceCoordY(i)=str2double(answerCoordY{1});
end
buildingTable=table(SpaceType,FloorNumber,SpaceX,SpaceY,SpaceZ,SpaceCoordX,SpaceCoordY);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!