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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by