How do I create a box in Matlab?

16 Ansichten (letzte 30 Tage)
Cassandra Dooner
Cassandra Dooner am 15 Apr. 2021
Bearbeitet: Cassandra Dooner am 15 Apr. 2021
Hi, I'm working on a little project where I need to make shapes that are able to rotate and be turned in gif/animation. In my class we have been using the box command, however I can't get it to work. When I run some the examples that we were given in class, they run, but when I change the numbers to fit what I need, it just doesn't work. This is what I have:
function boxtry3000
global Nx Ny Nz d color
Nx=100;
Ny=100;
Nz=100;
d=false(Ny,Nx,Nz);
coloe=char(zeros(Ny,Nx,Nz));
box(20,80,1,25,1,25,true,'k');
preview
model_gen
movefile('model.obj','boxtry3000.obj')
model_animate
movefile('model.gif','boxtry3000.gif')
end
I set up the function like we learned to, set the space domain, and attempted creating my 3D box that I'm looking for.
When I run it, I get this as an error;
I'm not sure how there's too many inputs, I have the x min and max, y min and max, z min and max, no hole, and the color.
What am I doing wrong?
  1 Kommentar
the cyclist
the cyclist am 15 Apr. 2021
It is infinitely better to paste code rather than images of code, which force us to re-type what you have.
You can either post code (and use the CODE format), or upload a *.m file.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

the cyclist
the cyclist am 15 Apr. 2021
Bearbeitet: the cyclist am 15 Apr. 2021
I don't think the box command does what you think it does. Maybe you intended rectangle?

Jan
Jan am 15 Apr. 2021
Bearbeitet: Jan am 15 Apr. 2021
box is a built-in Matlab command. It seems, like your teacher has shadowed this function with his own function. This is a bad programming practice and it can stop other toolbox functions from working.
I assume that you havbe stored the new "box" function in a folder, which is appended on the bottom of the path (where it does not cause collisions), while your teacher added the folder on top of the path (bad!). Check this:
which box -all
The version inside Matlab's toolboxes should appear on top.
The solution is easy: Rename your "box" function, e.g. in "drawBox".
The original box command accepts 1 or 2 input arguments: doc box

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by