Problem with adding dimension to array.
이전 댓글 표시
I'm trying to make it so the array doesn't overwrite itself every time the loop goes through. However on my current code, i get the error message 'Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts'. The lines this is occuring at look like, for example:
resdimensions(b,d,:)=e
Any help appreciated thanks.
numberoffloors=input('How many floors are there?');
for a=1:1:numberoffloors
spaces=input('How many spaces are on this floor?');
numberofspaces(:,a)=spaces
end
for b=1:1:numberoffloors
residential=input('How many residential rooms are there?');
office=input('How many offices are there?');
education=input('How many educational rooms are there?');
toilet=input('How many toilets are there?');
storage=input('How many storage rooms are there?');
c=[residential office education toilet storage];
total=0;
total=(residential+office+education+toilet+storage);
if total ~= numberofspaces(1,b)
message1=msgbox('The number of spaces does not equal the total of all the individual rooms. Please retry');
return
elseif total == numberofspaces(1,b)
room(b,:)=c
end
for d=1:1:residential
e=inputdlg({'What is the height of the residential room?','What is the depth of the residential room?'})
resdimensions(b, d, :)=e
n=inputdlg({'What is the x-coordinate of this room?','What is the y-coordinate of this room?'})
rescord=#
end
for f=1:1:office
g=inputdlg({'What is the height of the office room?','What is the depth of the office room?'})
offdimension(b, f, :)=g
o=inputdlg({'What is the x-coordinate of this room?','What is the y-coordinate of this room?'})
offcord=#
end
for h=1:1:education
i=inputdlg({'What is the height of the education room?','What is the depth of the education room?'})
edudimensions(b, h, :)=i
p=inputdlg({'What is the x-coordinate of this room?','What is the y-coordinate of this room?'})
educord=#
end
for j=1:1:toilet
k=inputdlg({'What is the height of the toilet?','What is the depth of the toilet?'})
toidimension(b, j, :)=k
q=inputdlg({'What is the x-coordinate of this room?','What is the y-coordinate of this room?'})
toicord=#
end
for l=1:1:storage
m=inputdlg({'What is the height of the storage room?','What is the depth of the storage room?'})
stordimension(b, l, :)=m
r=inputdlg({'What is the x-coordinate of this room?','What is the y-coordinate of this room?'})
storcord=#
end
end
댓글 수: 1
Krishna Bindumadhavan
2018년 5월 14일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!