how can i average array 1 based on values in array 2

I'm trying to average values of drag from CFD modeling. The velocities change based on the iteration. an example of My data is shown in the picture.
What i would like to do is separate the C_d at various points ie. 0-10k, 10k-20k, 20-30k etc. problem is the data is not rigid ie the difference between each data point is not regular, so some version of the find function i assume would likely be needed.
then i would like to see (plot) each section to better visualize and see how long the section took to stabilize. once stabilized, i would like to take the mean for each section. for example.
  • find 0-10k plot 0-10k mean 2k-10k
  • find 10-20k plot 10k-20kmean 14k-20k
I can write the loop once i am able to 'find, plot and mean' my data. Any help would be greatly appreciated

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 15 Feb. 2014
c1=40*sort(rand(40,1))
c2=rand(40,1)
[ii,jj]=histc(c1,0:10:40);
ii=[0 ;cumsum(ii(1:end-1))]
for k=1:numel(ii)-1
idx=ii(k)+1:ii(k+1);
plot(c1(idx),c2(idx))
moy{k}=mean(c2(idx))
hold on
end
hold off

Diese Frage ist geschlossen.

Gefragt:

am 15 Feb. 2014

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by