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!