Resample the output file of a simulation
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a matrix containing two columns as output of my simulation. In the first column I have the position, and in the second one my variable. I used a high resolution in my simulation, but I would like to bin the results. I scored my variable every 1 millimeter in x, but I want to plot it every 1 cm to have a smoother curve, summing 10 voxels at the time. How do I do that? Is there a simple variable to bin the data summing every 10 entries? Can I sum in a non uniform way too (first 5, and then every 10, then the last 5 voxels)? At the moment I am using a simple plot (x, v) function. Thank you!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284521/image.png)
댓글 수: 0
답변 (1개)
Ayush Gupta
2020년 6월 3일
The following procedure might help you, where X is the second column of the matrix which needs to be binned:
bins = [start_position of x (in mm): 10: end_position of x (in mm)+1]
Y = discretize(X,bins) will give which value belongs to which bin
To get number of values in a bin following can be used:
[Y,E] = discretize(X,bins,diff(bins))
Where Y will give each bin’s count and E will give the bins
The above procedure can be followed for uniform bins but for non-uniform bins, it can defined as -
bins = [start_position of x (in mm), start_position of x (in mm) + 5 (in mm) :10: end_position of x (in mm) - 4(in mm) , end_position of x (in mm)+1] .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!