# 3d plot - 4 dimensional array

조회 수: 2 (최근 30일)
Alex 2012년 6월 30일
Hello!
I just completed a large simulation task, whose output is a 4 dimensional array, say A, with 1 (conditions satisfied) and 0 (conditions not satisfied) elements only. The dimensions are as follows:
dimension 1: simulation number, here 10000
dimension 2: input variable 1
dimension 3: input variable 2
dimension 4: input variable 3
I am interested in knowing in how many % of cases the conditions are satisfied. For given input variables I can do the following:
mean(A(:,1,1,1))
and I will get one number, say 0.75. If I use another input varaible 1, then
mean(A(:,2,1,1))
which will also give me a number, say 0.81.
What I want to do is to make a 3d plot where:
• input variable 1 is frozen. Say I only want my plot to be based on A(:,1,:,:). Hence one dimension disappears.
• input variable 2 and 3 are the explanatory variables
• mean of the elements for different input variables is the dependent variable.
I would to make a plot both with points in the 3d space only and as a "carpet" in the 3d space.
Thank you very much in advance!
Alex

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

### 답변 (2개)

Walter Roberson 2012년 6월 30일
surf( squeeze( mean( A(:,V1,:,:), 1 ) ) )
##### 댓글 수: 4이전 댓글 2개 표시이전 댓글 2개 숨기기
Alex 2012년 7월 2일
When I use "mesh", it uses the array indices, so for example if the 3rd dimension has length 10 (input variable 2), the axis gets indices from 1 to 10. However, in my case each index refers to different values of an input variable: alpha = 1%, 3%, 5%, ... , 19%. My question is how I can get matlab to print "1%, 3%", etc. and give then axis label "alpha"? Right now there is no label and the axis has indices 1 to 10. Thanks in advance!
Walter Roberson 2012년 7월 2일
set(gca, 'ZTickLabel', {'1%', '3%', '5%', ... '19%'} ) zlabel('alpha');

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

Image Analyst 2012년 6월 30일
편집: Image Analyst 2012년 6월 30일
You can get a 3D array by doing
array3D = squeeze(A(:,1,:,:));
Now each slice in this 3D array is the #1 slice of the 3D array at different simulation numbers. Then you can average over all simulation numbers like this:
meanXYView = squeeze(mean(array3D , 1));
Now you have a 2D image which is the average view of "input variable 1" at a value of 1 averaged over all simulation runs. You can then view this with imshow(), image(), surf() or whatever. Is that what you're after?

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

### 카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by