Azzera filtri
Azzera filtri

size Inputs must be scalar

5 visualizzazioni (ultimi 30 giorni)
Hege
Hege il 25 Lug 2020
Commentato: Hege il 25 Lug 2020
I want to develop a 3D cubes systematically from 5x5x5 to 15x15x15 with the increments of 1.I developed below code.But there is a problem in the way I am giving the inputs of x,y,z with the increments.
x=5:1:15;
y=5:1:15;
z=5:1:15;
B=zeros(x,y,z);
for i =1:x;
for j=1:y;
for k=1:z;
if ((j==1)|(j==y))&((k==1)|(k==z));
B(i,j,k)=1;
else B(i,j,k)=0;
if((i==1)|(i==x))&((k==1)|(k==z));
B(i,j,k)=1;
else B(i,j,k)=0;
if ((i==1)|(i==x))&((j==1)|(j==y));
B(i,j,k)=1;
else B(i,j,k)=0;
end
end
end
end
end
end
Error
Error using zeros
Size inputs must be scalar.
Error in (line 6)
B=zeros(x,y,z);

Risposta accettata

madhan ravi
madhan ravi il 25 Lug 2020
B = zeros(numel(x), numel(y), numel(z)); % error is gone but I have no idea what’s going on
  3 Commenti
madhan ravi
madhan ravi il 25 Lug 2020
Modificato: madhan ravi il 25 Lug 2020
for x = x
for y = y
for z = z
zeros(x, y, z)
end
end
end
doc zeros
Hege
Hege il 25 Lug 2020
Thank you sir.I got the answer.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Prodotti


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by