Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello again, I need to use these math functions in my problem.

First of all, I have an list of values which first I use the abs and log10 math functions.
Now, I need to use these 2 equations in that array.

1. x=ceil(30*log10(arrData))+1
2. y=floor(30*log10(arrData))

And then, I need to make this calculation : newsetdata=y-x+1

I create 2 lists, the 1st is the arrData which I used the ceiling , and the arrData2 is the floor.

now I want to create a new list that I can use this equation -> arrData2-arrData+1 and I can't do this...some help?

What I have tried:

Dim strFileName = IO.File.ReadAllLines("C:\Users\x-ios\Desktop\1234.txt")
Dim cu As Globalization.CultureInfo = Globalization.CultureInfo.CreateSpecificCulture("en-US")
Dim style As Globalization.NumberStyles = Globalization.NumberStyles.Number Or Globalization.NumberStyles.AllowCurrencySymbol

Dim arrData = strFileName _
.Select(Function(x) New With _
{
.FirstCol = Math.Ceiling(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu))), _
.SecondCol = Math.Ceiling(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu)))) _
}) _
.ToList()


Dim arrData2 = strFileName _
.Select(Function(x) New With _
{
.FirstCol = Math.Floor(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu)))), _
.SecondCol = Math.Floor(Math.log10(Math.Abs(Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu)))) _
}) _
.ToList()
Posted
Updated 19-May-17 11:02am
v3
Comments
OriginalGriff 19-May-17 6:39am    
And?
What is the problem?
Where are you stuck?
What help do you need?
Have you looked at the official documentation, and if so, why didn't that help you?
x-ios 19-May-17 6:54am    
Yes, you are right. I update the question...
Maciej Los 19-May-17 15:51pm    
arrData2-arrData+1 ???
arrData is a set of data: FirstCol and SecondCol. What calculation exactly do you need?
x-ios 19-May-17 16:05pm    
Yes, anewsetdata=arrData2-arrData+1.
How can I do it?
Maciej Los 19-May-17 16:06pm    
Sorry, but are you blind? arrData is set of data. Please, read my previous comment.

1 solution

Quote:
Yes, I mentioned that x=ceil(30*log10(arrData))+1 , y=floor(30*log10(arrData)), and I accomplished them (arrData is the x ,and y is the arrData2) . And now I need : newdataset=y-x+1
(I update the question, because I forgot to mentioned it, by mistake)


All you need to calculate result is:
VB.NET
Dim arrData = strFileName _
	.Select(Function(x) New With _
		{
			.a = Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(0), style, cu), _
			.b = Double.Parse(x.Split(New String(){Microsoft.VisualBasic.vbTab}, StringSplitOptions.RemoveEmptyEntries)(1), style, cu) _
		}) _
	.ToList()

	For Each d In arrData
		Dim x = Math.Ceiling(30*Math.Log10(d.a))+1
		Dim y = Math.Floor(30*Math.Log10(d.b)) 
		Console.WriteLine("{0}-{1}+1={2}", y, x, y-x+1)
	Next


Reult:
-11--38+1=28
-8--35+1=28
-5--33+1=29
-3--31+1=29
-1--30+1=30
0--29+1=30
...


Change the code to your needs, if i misunderstood you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900