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.
类别
在 帮助中心 和 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!

