^[0-9.9]{0,6} - How can I make this only accept numbers up to 100? - range

Obviously this is accepting each number as input but what I don't know how to do is to make this accept numbers up to 100. Trying to solve for it recognizing the number as individual digits rather that up to 3 numbers from 0 - 100.
Thanks.

I solved this.
\b([1-9]|[1-9][0-9]|100)\b.{0,5}

Related

why does this variable return negative value?

i have a variable with initial value : 34-640.4-71.2.
It should appear 0,instead the result is negative. Could you please tell me the reason? thanks
This has to do with how variables are stored in Java.
double variables are precise up to a certain number of decimals digits. In your equation, while none of its parts exceed 1 decimal, rounding is done in the binary format causing this very minor inaccuracy at the 16th decimal.
-1.776E-15 is equal to -0.000000000000001776.
Here is an interesting thread that can give you more insights on the topic:
Whats wrong with this simple 'double' calculation?
One thing you can do to overcome your problem is to round off the error using:
roundToDecimal( 34 - 64*0.4 -7*1.2 , 14 )
This would round your number to 14 decimal places thus rounding off the inaccuracy.

matlab textscan gives me wrong number of lines

I have a file names inputR_revised.tsv at https://www.dropbox.com/s/vtby4027rvprhga/inputR_revised.tsv?dl=0
In matlab, I typed
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',1);
I get covTable{1,1} of size 41699 times 1. However when I type the following at terminal
wc -l inputR_revised.tsv
I get 41677.
Why does it differ? I have used sed and cut to modify the original file to get inputR_revised.tsv. Is this the reason?
Is there a way to fix this?
%.8 is not enough if you have decimals printed with more than 8 digits. For these cases digits after the 8th decimal could be treated as a separate entry. That will make more numbers than expected. You should use a higher value for number of decimals in the scan format. For example,
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.18n',[1,20])],'HeaderLines',1);
This should give you the correct number of rows.

Same value must exist at least 3 times in a Matrix

The matrix <1x500> consists of different values, now I want to check if any of the values in the matrix occurs at least 3 times or more.
if (val occurs 3 times or more)
do
Help is very appreciated!
Another option from #KiW answer for when you need to know all the values that do appear at least 3 times is:
uniqA=unique(A);
counts=histcounts(A,[uniqA inf]);
vals_that_are_bigger=uniqA(counts>=3);
To check if any of them are bigger than 3, just
if any(counts>=3)
if numel(find(matrix)==val)>3
whatever you want to do
end

Random Number in Octave

I need to generate a random number that is between .0000001 and 1, I have been using rand(1) but this only gives me 4 decimal points, is there any other way to do this generation?
Thanks!
From the Octave docs:
By default, Octave displays 5 significant digits in a human readable form (option ‘short’ paired with ‘loose’ format for matrices).
So it's probably an issue with the way you're printing the value rather than the value itself.
That same page shows the other output formats in addition to short, the one you may want to look in to is long, giving 15 significant digits.
And there is also the output_precision which can be set as per here:
old_val = output_precision (7)
disp (whatever)
old_val = output_precision (old_val)
Set the output_precision to 7 and it should be ok :)
Setting the output precision won't help though because the number can still be less than .0000001 in theory but you will only be displaying the first 7 digits. The simplest way is:
req=0;
while (req<.0000001)
req=rand(1);
end
It is possible that this could get you stuck in a loop but it will produce the right number. To display all the decimals you can also use the following command:
format long
This will show you 15 decimal places. To switch back go:
formay short

Matlab number formatting?

I'm having some difficulties processing some numbers. The results I get are some like:
0.000093145+1.6437e-011i
0.00009235+4.5068e-009i
I've already try to use format long and as alternative passing to string and then str2num and with no good results also. Although is not being possible to convert them properly as I want (e.g. to a number with 9 decimals) If nobody is able to help me, at least I would appreciate if someone can tell me how to interpret the meaning of the i base.
You are talking about the imaginary unit i. If you are just using real number, you could neglect the imaginary part (it is very small). Thus, try:
real(0.000093145+1.6437e-011i)
After taking real() you can also control the decimal place formatting by sprintf:
sprintf('%0.2f', pi)
Will result in:
'3.14'
Place a 9 instead of a 2 for 9 decimal places.