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!
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!