3d plot - 4 dimensional array

2 次查看(过去 30 天)
Alex
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.
Could you please help me with this problem?
Thank you very much in advance!
Alex

回答(2 个)

Walter Roberson
Walter Roberson 2012-6-30
surf( squeeze( mean( A(:,V1,:,:), 1 ) ) )
  4 个评论
Alex
Alex 2012-7-2
Thank you! Could you please help with one more detail:
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
Walter Roberson 2012-7-2
set(gca, 'ZTickLabel', {'1%', '3%', '5%', ... '19%'} ) zlabel('alpha');

请先登录,再进行评论。


Image Analyst
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 中查找有关 Graphics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by