Figuring out the most fitting prefix for a vector dataset
이전 댓글 표시
Hello fellow Matlab users,
I'd like to ask for your advice concerning a numerical topic. So I mainly use Matlab for simulation purposes (electrical circuits). My simulations return vectors containing state variables and power / energy quantities. I'm trying to fully automate a report generation with Matlab code but I'm facing a small problem. I'd like to determine the best prefix for a data set. So for example I get a vector with 1000 values. My initial idea was to get the exponents through a mathematical trick floor(10log10(vect)) and then calculate the mean of the vector containing the exponents, which would give me the mean exponent. From the exponent I can determine the nearest prefix (milli, micro...) . My problem is that some simulations return values with an accuracy of 10e-80 which totally falsifies the mean. So do you guys have any idea on how to basically get the mean exponent of a vector dataset ?
I appreciate all your thoughts and answers
댓글 수: 6
Adam Danz
2020년 5월 28일
What about mode() instead of mean()? Median is better than mean, too.
Bakr Al Beattie
2020년 5월 29일
Ameer Hamza
2020년 5월 29일
What about ignoring the zeros and use the median value as suggested by Adam
median(nonzeros(x))
Bakr Al Beattie
2020년 5월 29일
Adam Danz
2020년 5월 29일
So, try it out, then.
median(x(abs(x)>1e20)) % play around with the threshold value.
If that doesn't work, plot the vector of values and show us the results. Something like this would be useful
figure()
subplot(2,1,1)
plot(y,'o-')
subplot(2,1,2)
histogram(y)
Bakr Al Beattie
2020년 6월 5일
편집: Bakr Al Beattie
2020년 6월 5일
답변 (1개)
Adam Danz
2020년 6월 5일
There are no axis labels on the histogram so I'm not sure what it represents. If it represents a distribution of y-values for the orange line in the first subplot, I'd expect a giant bar at x=0 but I don't see that.
I don't undersant what the problem is with taking the median of values greater than some very small number.
m = median(vector(abs(vector)>0.001));
You can play around with the threshold value. If you zoom into the axes using ylim([-.001,.001]) you can see whether all of the undesired data fall into those limits.
댓글 수: 1
Bakr Al Beattie
2020년 6월 5일
편집: Bakr Al Beattie
2020년 6월 5일
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

