3D array becomes 4D Array

Hi,
I use in matlab Simulink a matlab fcn blok to create a 3D array. That is the function:
function y = fcn()
X_welt=10;
Y_welt=10;
Z_welt=10;
welt = zeros(X_welt,Y_welt,Z_welt);
y = welt;
and I use additionally to workspace blok to load that into the matlab workspace. But the problem ist i get a 4D array val(:,:,1,1) =...
Why does it change the dimension???
THX

답변 (1개)

Jan
Jan 2013년 7월 22일

0 개 추천

A trailing dimension of 1 can always be appended in Matlab. This still replies the 2nd element:
x = rand(3, 1);
disp(x(2, 1, 1, 1, 1, 1, 1, 1))
So please explain what "i get a 4D array val(:,:,1,1) =..." exactly means. Please post the complete code you use to identify the problem.

댓글 수: 3

sia
sia 2013년 7월 22일
hi, as well as you see i create a 3D array with zeros. E.g.
>> a= zeros(2,2,2)
a(:,:,1) =
0 0
0 0
a(:,:,2) =
0 0
0 0
end
That works in matlab workspace. Now i wanna create this 3D array in Simulink matlab fcn blok and i wanna load it with "to workspace blok" into the matlab workspace. But the problme is i get everytime 1 dimension more than expacted. I get such like that:
val(:,:,1,1) =
0 0
0 0
val(:,:,2,1) =
0 0
0 0
val(:,:,1,2) =
0 0
0 0
.......
Jan
Jan 2013년 7월 22일
Please do not post something, that is similar to what you get, but show us exactly what you get. What does size(val) return?
When you explain how you create this variable and how it is changed afterwards, we will find the reason for the results.
sia
sia 2013년 7월 23일
I've already explained, i have a simulink model, and there i use matlab fcn block for creating a 3D array. i try to give the output to workspace. if i do that my 3D array becomes 4D array. maybe you can try it. use in simulink matlab fcn blok and create a 3D array like above, then the connenct the output with "to workspace" blok. and u can see the result in matlab workspace.

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

카테고리

태그

질문:

sia
2013년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by