create a test environment with the size 10x10x10cm

조회 수: 2 (최근 30일)
sia
sia 2013년 5월 29일
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
Walter Roberson
Walter Roberson 2013년 5월 29일
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.
Walter Roberson
Walter Roberson 2013년 5월 29일
Please read the guide to tags and retag this question; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags

댓글을 달려면 로그인하십시오.

답변 (2개)

Muruganandham Subramanian
Muruganandham Subramanian 2013년 5월 29일
편집: Muruganandham Subramanian 2013년 5월 29일
>> B = zeros(10,10,10); %Try this
  댓글 수: 3
sia
sia 2013년 5월 29일
편집: sia 2013년 5월 29일
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?

댓글을 달려면 로그인하십시오.


sia
sia 2013년 5월 29일
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
Walter Roberson
Walter Roberson 2013년 5월 29일
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.
sia
sia 2013년 5월 29일
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?????

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by