top of page

Data Types and the Black Hole

by Carina Butterworth

May 20,2021


Coding is a challenge to start with. Just trying to keep one's thoughts in a sequential format to get the computer to do as it's told is borderline insanity, but it is what runs our world as we know it. Once the extra layer of data types is added to this, it's like creating a whole new dimension of insanity to the process. Honestly, trying to get my head wrapped around data types in coding is some serious brain flexibility that I struggle to achieve. Let's start out with where this comes from.


I managed to get my figures all ready for my presentation tomorrow and have the presentation developed in Prezi. This is the easy part of the day for me. The hard part was when I thought I would look into frequency tuning and histograms. I was like, "Hey, I want to see what these look like with phase, so let's do it!" This is not a quick venture in coding as I found out. Never try to use examples from a different discipline line by line in coding. It definitely doesn't work.

Photo credit to broadband4europe.com

But never mind my complaints there, I want to get into today's topic of my learning and what I needed to venture to apply in my code. And that is on data types. Computer really think of data in one way and that is binary where everything else is translated from some other version to that binary system. The software used for coding today changes and manipulates the information or instructions one puts in for the computer to do the work. To do this, the software needs to classify the types of data that the user is putting in. Here are some that I have had to work with while dealing with my code:


Integers

Doubles

Characters

Complex

Vectors

Arrays

Strings

Cells

Structs


Starting out with the easy ones - integers, doubles, and characters - these are single numbers or characters that are saved. Integers are only whole values with no decimals. They get complicated when you start talking about unsigned versus signed and how many bits are stored. So, for example, the amount of memory can vary from 8 to 64 bits, so with a quick calculation, that is EIGHT different kinds of integers. When working with images in Matlab, as I am currently doing, it uses 8 bit unsigned integers for each pixel value to save memory (because we know that any kind of image can have a lot of data to store to memory). Doubles, on the other hand, are values with decimals. Matlab can hold up to 16 decimals and do calculations with that precision. Generally speaking, most engineering calculations are doubles, so I use them a lot too, but that means that I need to convert doubles to 8 bit unsigned integers to display my data correctly. Oh the fun! Characters are a bit of a side thing. I get the user of my code to enter a couple options, which are ASCII characters (like the ones you see on your screen), then the computer converts that character to a number for storage. I only use it for flexibility for the user of my code, I don't do the fancy stuff that computer scientists and software engineers can do.


Then I work with complex numbers, vectors, arrays, and strings. I'm grouping these together because they all kind of act the same way. Complex numbers have two values: a real component and an imaginary component. One can think of complex numbers as a two dimensional coordinate system with real values on the X and imaginary values on the Y. I promise I won't get into the math on this, but it is some serious fun with trig. Vectors are a list of numbers in a row or column where arrays are two dimensional values in a matrix. Strings are the exact same, except they use characters in each place of the number; and I use strings for determining file paths for each file I'm looking at. I use vectors to hold numbers of doubles when looking at only one signal, I use arrays when looking at all the signals or at the images. A black and white image is actually just an array - with each pixel being a single number. Well, to be honest, I use arrays up to four dimensions, but that just adds some complexity to what I'm talking about here. Let's talk multidimensions on my forum!



The last two are my nemesis. Cells and structs. Honestly, they are super helpful in storing all kinds of data but accessing the data in these becomes a nightmare. Cells hold different types of data in each element. This is awesome when you have different sizes of arrays from the signals but you still need to keep all the signals together. Structs allow you to save all kind of information with titles. This is also awesome for anyone who needs to come back to your code and try to figure out what you did. But accessing the data within each will make a dragon cry. You need to use (), or {}, or [], or '', or . In what order, depends on the mood of the computer of the day. And it might change it's mind depending on the humidity in Fiji. Or maybe it is the barometric pressure on Jupiter's moon, Io. I don't know. It is super easy to store the data in them, but the coding protocols lock the data away and love to give you error messages. I'm sure my computer gets a thrill out of sending me these error messages. Here's some fun ones for you to enjoy:


variable{ii}(1,2)

variable.name{ii,2}

variable(z).name(variabletwo{yy}).variable(jj,5)


Don't ask, because I don't know. They just all jumble together in some wild crazy way with layers and layers of data. When it works you can make really cool images from signals to look like space invaders!


“Let your joy be in your journey—not in some distant goal.” —Tim Cook
37 views0 comments

Recent Posts

See All

Success in the Project!

Going into this neuroscience workshop, I thought I'd be dealing with neural data. I was hoping to work with EEGs (electroencephalograms) but it turned out I could work on my own project. This was su

Post: Blog2_Post
bottom of page