How do I create a box in Matlab?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
the cyclist
le 15 Avr 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.
Réponses (2)
Jan
le 15 Avr 2021
Modifié(e) : Jan
le 15 Avr 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".
0 commentaires
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!