3d plot - 4 dimensional array
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Walter Roberson
on 30 Jun 2012
surf( squeeze( mean( A(:,V1,:,:), 1 ) ) )
4 Comments
Walter Roberson
on 2 Jul 2012
set(gca, 'ZTickLabel', {'1%', '3%', '5%', ... '19%'} ) zlabel('alpha');
Image Analyst
on 30 Jun 2012
Edited: Image Analyst
on 30 Jun 2012
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?
0 Comments
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!