Figuring out the most fitting prefix for a vector dataset
Mostrar comentarios más antiguos
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 comentarios
Adam Danz
el 28 de Mayo de 2020
What about mode() instead of mean()? Median is better than mean, too.
Bakr Al Beattie
el 29 de Mayo de 2020
Ameer Hamza
el 29 de Mayo de 2020
What about ignoring the zeros and use the median value as suggested by Adam
median(nonzeros(x))
Bakr Al Beattie
el 29 de Mayo de 2020
Adam Danz
el 29 de Mayo de 2020
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
el 5 de Jun. de 2020
Editada: Bakr Al Beattie
el 5 de Jun. de 2020
Respuestas (1)
Adam Danz
el 5 de Jun. de 2020
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 comentario
Bakr Al Beattie
el 5 de Jun. de 2020
Editada: Bakr Al Beattie
el 5 de Jun. de 2020
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

