3d plot - 4 dimensional array
2 次查看(过去 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
0 个评论
回答(2 个)
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?
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!