Why is it that Matlab has so many data types?

1 view (last 30 days)
list many data types for Matlab. Why is it that they developed so many data types in Matlab?

Accepted Answer

John D'Errico
John D'Errico on 30 Nov 2020
Edited: John D'Errico on 30 Nov 2020
So? If you don't need them, then something you don't use has no impact on you. MATLAB is a complex, powerful language, that can be used to perform a huge variety of things. And not everything is best done with the same tools.
Would you expect a stone mason, an electrician, a plumber, and a carpenter to all use the same set of tools?
  3 Comments
John D'Errico
John D'Errico on 30 Nov 2020
Yes. Some languages do. I'd bet that c++, Java, and Python all have dozens of comparable of ways to solve a problem. You want that capability, because not everybody solves the same problems, and not everyone wants to think the same way. And we can easily contruct our own classes, as I have done many times. I've writtten and published three useful classes for different purposes on the file exchange. And I've written at least three others I never did post.
MATLAB is a language that is now, what 35 years old and counting? In the beginning, there were numbers. You could do anything you wanted, as long as it was in double precision. Pretty quickly, character arrays appeared. And single precision appeared as an option, because a double was not perfect for all purposes. People started to need integer types, because some computations just cry out for integer arithmetic. But how big of an integer? One byte, 2 bytes? 4 bytes? 8 bytes? Different problems cry out for different tools. Signed or unsigned integers?
And those are just the numeric classes for data. Every single one of them makes sense to some person out there. (Ok, I almost never use singles. And if I'm going to use a strictly integer type, it will be either uint8 or int8, or uint64 or int64.) And there is no way i would ever want to be without the ability to do symbolic computations in MATLAB, so syms are a complete necessesity.

Sign in to comment.

More Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 30 Nov 2020
Partial "answer":
In the beginning there were the double (32-bit?) and the char, and everything was peaceful, then they ate of the forbidden fruit and saw that there were special use-cases where new types would be beneficial, large images (gray or colour) could be much easier handled in a smaller bit-format, so they started to multiply, the int8, then the int16 and all their signed and unsingned siblings, and suddendly you could no longer index arrays with flints - but you got to use multidimensional arrays, then there was a struct and cell and they were ever so handy, then there was a function-handle that came walking by and made space...
(others could join in...)
Every data-type have its useful use-cases where they are ever so handy, when working with large images that have 8-bit intensities it can be handy not having to convert them to 32(64?!)-bit double data, just to not waste space. Structs and cell-arrays are very convenient types to bundle data of various types that should "go together" (for one reason or other). Time is a notoriously messy data-type to handle well and generally (daylight-savings-time, midnight and elapsed times and time-zones and on and on...) so a proper set of functions for handling all of that.
  1 Comment
alpedhuez
alpedhuez on 30 Nov 2020
"Every data-type have its useful use-cases where they are ever so handy." True. Maybe helpful to color-code different data types automatically in one way or the other?

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!