I am trying to work out a volume given input values but it says theres an error ''Index must not exceed 1''?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to work out volume of building using number of floors, width of floors, length of floors and height of floors but when it comes to working it out an error comes up about index exceeding number of array elements and says ins=dex must not exceed 1. Im not sure how to fix this.
n=1;
Building = input('Enter Building name: ','s');
while isempty(Building)
Building = input('Enter Building name: ','s');
end
sBuilding(n).bName =Building;
sBuilding(n).bNoOfFloors = input('Enter Number of Floors as an integer: ');
NumberOfFloors = sBuilding(n).bNoOfFloors;
sBuilding(n).bWidth = input('Enter the floors width as an integer: ');
WidthOfFloors = sBuilding(n).bWidth;
sBuilding(n).bLength = input('Enter the floors length as an integer: ');
LengthOfFloors = sBuilding(n).bLength;
sBuilding(n).bHeight = input('Enter the floors height as an integer: ');
HeightOfFloors = sBuilding(n).bHeight;
BuildingVolume= NumberOfFloors(WidthOfFloors*LengthOfFloors*HeightOfFloors);
disp('Building volume is:'+BuildingVolume)
disp("")
0 Commenti
Risposta accettata
the cyclist
il 3 Mag 2022
This expression:
NumberOfFloors(WidthOfFloors*LengthOfFloors*HeightOfFloors)
is trying to index into the variable NumberOfFloors.
Did you perhaps mean
NumberOfFloors*WidthOfFloors*LengthOfFloors*HeightOfFloors?
Also, you cannot concatenate character array and numbers with this syntax:
disp('Building volume is:'+BuildingVolume)
You can use a string instead:
disp("Building volume is:"+BuildingVolume)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 3-D Volumetric Image Processing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!