Is there a way that we can identify the output of the figures that fall within the assigned range?

1 Ansicht (letzte 30 Tage)
Hello,
My scenario is that i am assigning the interval manual for the output figures.... it is rather tidious when dealing with many figures
Output = [ - 1.05 2 -3.6 0.5 -0.75 1.4 2.2]
The intervals are
1 [-4 -2]
2[-2 0 ]
3[0 2]
4[2 4]
Now, in matlab my codes are as follows:
output = [ - 1.05 2 -3.6 0.5 -0.75 1.4 2.2 ] %matrix
inter = [-2 0; 0 2; -4 -2; 0 2; -2 0; 0 2; 2 4] % input manually
Now, normally i need to calculate the mean of the respective interval and multiply it by the output to get the answer.
finaloutput = output.*(mean(inter,2)/2*100)
Is there any way that the intervals can be assigned directly without me assigning as show above?
Grateful for any help
Thank you

Akzeptierte Antwort

Steven Lord
Steven Lord am 14 Sep. 2019
Use the discretize function.

Weitere Antworten (1)

Krishma Gold
Krishma Gold am 15 Sep. 2019
Any help with the codes please, with regards to the above scenario
dist = [ - 1.05 2 -3.6 0.5 -0.75 1.4 2.2 ]
DistEdges = [-4 -2 2 4]
[n, bin] = histc(dist, DistEdges)
splitapply(@mean, DistEdges(:,1), bins)
what about if I have irregular intervals?

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by