create a test environment with the size 10x10x10cm

1 view (last 30 days)
sia
sia on 29 May 2013
Hi,
i wanna create a test environment with the size 10x10x10 cm. This should be my workspace and there is no electrical resistance or something like that. there is only air. Then i want to place a cube in the center of that.
But I dont know, how i can create such of matrix.
Can u guys help me pls??? THX
  2 Comments

Sign in to comment.

Answers (2)

Muruganandham Subramanian
Muruganandham Subramanian on 29 May 2013
Edited: Muruganandham Subramanian on 29 May 2013
>> B = zeros(10,10,10); %Try this
  3 Comments
sia
sia on 29 May 2013
I dont think this link helps me :(.... I wanna write a function to build that. something like that:
function test_environment
x = 10;
y = 10;
z = 10;
workspace = zeros(x,y,z);
for i=1:1:x
for j=1:1:y
for k=1:1:z
% here i have to include the second matrix B = onse(2,2,2)
end
end
end
end
But i dont know how :( Any idea?

Sign in to comment.


sia
sia on 29 May 2013
I changed my funktion to this :
function test_environment
workspace = zeros(10,10,10);
cube = ones(2,2,2);
[r,c,d]=size(cube);
xpos=2;ypos=2;zpos=2;
workspace(xpos:xpos+r-1,ypos:ypos+c-1,zpos:zpos+d-1)=B;
end
but when i try to call it like this :
>> test_environment
i get this error:
Undefined function or variable 'test_environment'.
do u se my fail???
  2 Comments
sia
sia on 29 May 2013
I found this problem thx :)
another question: i wanna display the result i use at the mom
printmat(workspace )
but this is not smart. because i gt this:
--1--> --2--> --3--> --4--> --5-->
--1--> 0 0 0 0 0
--2--> 0 0 0 0 0
--3--> 0 0 0 0 0
--4--> 0 0 0 0 0
--5--> 0 0 0 0 0
--6--> 0 0 0 0 0
and .... I think i get all columns, how can i formate this?????

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!