create a test environment with the size 10x10x10cm

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 个评论

How finely grained should the cube be? If it is 10 cm per side, do you need it sub-divided into mm ? You mention electrical resistance and air: if you are going to model air-gap electric field breakdowns, then 1 mm per step might be too much for realistic modelling.

请先登录,再进行评论。

回答(2 个)

>> B = zeros(10,10,10); %Try this

3 个评论

and how can i place the cube with the size 1x1x1cm in the center of my workspace????
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?

请先登录,再进行评论。

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 个评论

You need to save that code to test_environment.m somewhere on your MATLAB path.
Note: you will not see any output from this function. When it executes it will construct values within its local workspace, and then when the function executes the workspace will be destroyed, leaving you with no net effect.
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?????

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

提问:

sia
2013-5-29

Community Treasure Hunt

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

Start Hunting!

Translated by