Use importdata with more than 4 digits precision [duplicate] - matlab

This question already has an answer here:
Importing Data to Matlab
(1 answer)
Closed 8 years ago.
My data is a mixture of strings and values tab delimited. 'Importdata' is working pretty well but doesn't have a higher precision than 4 digits. How can I fix that, because I really need more?
Thanks in advance!

Matlab shows you by default only a precision of 4 digits - but calculates with much more digits internally.
Try
format long
to see a more precise representation of your data

Related

wrong answer from dart for a simple addition operation [duplicate]

This question already has answers here:
Dart rounding errors
(2 answers)
Is floating point math broken?
(31 answers)
Closed 8 months ago.
I couldn't resolve the following quirk when doing simple addition in Dart.
void main(){
print(5.9+0.7);
}
The output is:
6.6000000000000005
But when I use some different numbers ;
void main(){
print(5.9+0.6);
print(5.9+0.7);
print(5.9+0.8);
print(5.9+0.9);
}
The output is :
6.5
6.6000000000000005
6.7
6.800000000000001
And here is a different example :
void main(){
print(25.90+20.70+4);
}
The output is :
50.599999999999994
What may be the reason of this strangeness.
Is there ay solution suggestion to solve this problem?
I'd recommend you read this article: What Every Computer Scientist Should Know About Floating-Point Arithmetic
From this article, Rounding Error - Squeezing infinitely many real numbers into a finite number of bits requires an approximate representation. Although there are infinitely many integers, in most programs the result of integer computations can be stored in 32 bits. In contrast, given any fixed number of bits, most calculations with real numbers will produce quantities that cannot be exactly represented using that many bits. Therefore the result of a floating-point calculation must often be rounded in order to fit back into its finite representation. This rounding error is the characteristic feature of floating-point computation.

How to give the matlab "find" function a hint that the list is sorted? [duplicate]

This question already has answers here:
Faster version of find for sorted vectors (MATLAB)
(5 answers)
Closed 7 years ago.
I want to use find function in matlab to find the index of first value that is bigger than a number C. the list is too long and it takes a lot of time to execute. But the values are actually sorted in increasing manner. How can I take advantage of that feature of data in matlab?
find(Data>C,1,'first')
set the 'first' switch in find. This will ensure that as soon as it finds the first element satisfying the criterion it will stop looking.

Extracting data from a very large dataset using matlab [duplicate]

This question already has an answer here:
Extracting unique data from large .txt files [closed]
(1 answer)
Closed 9 years ago.
http://tinypic.com/r/2dt5ge1/5
this is the link of screen shot of data which i want to extract.Data contains total 5,00,000 records/rows, what i want to do is, extract only those rows which has 19 at a particular position.
As you can see in the 9th and 19th row, after two 350 in the middle, there is 19. So i want to extract these rows only.Please help.
Also how many columns should i make while importing and in which format(text or numeric).
The data set is not really large, I would import everything and filter then. Using a numeric format, your data is <500MB which should be no Problem.
Start here: http://www.mathworks.de/de/help/matlab/import_export/import-numeric-data-from-a-text-file.html
To filter your data quick, use logical indexing e.g. data(data(:,4)==19,:) which would select every row where the 4-th column is 19.

Eliminating common factor in display of MATLAB matrices

What I am trying to do is probably relatively simple.
As you see, this matrix is being displayed such that all terms are to be multiplied by 1.0e+04. I want to disable this feature and see the numbers as they "really" are.
The format command can fix this for you. From the docs:
FORMAT SHORT Scaled fixed point format with 5 digits.
FORMAT LONG Scaled fixed point format with 15 digits for double
and 7 digits for single.
These are the defaults, and what you want is:
FORMAT SHORTG Best of fixed or floating point format with 5
digits.
FORMAT LONGG Best of fixed or floating point format with 15
digits for double and 7 digits for single.

Segregating digits from an image in matlab [duplicate]

This question already has answers here:
segment digits in an image - Matlab
(2 answers)
Closed 9 years ago.
I am doing a project to recognize the digits in a calculator screen. The full image is shown
.
After some image processing, I have extracted only the screen from the full image as shown
.
But the digits are getting overlapped. Can anyone suggest how to remove the bridges or connections between the images?? Would any morphological image processing using bwmorph() be of utility? Please help..
May be you can try these two ideas see where it takes you
1). I would clean up the salt and pepper noise first.
2). then use erodedBW = imerode(originalBW,se)
of course you have to play aroud with se to find the one that works best for you.