# Loren on the Art of MATLAB

## New Datatype under Development for Possible MATLAB Release

There is a new datatype we are playing around with that we hope to make available in an upcoming release and we would like your input beforehand.

### Contents

#### New Datatype in Action

Let me show you the new datatype in action so you can first get a feel for it.

inputData = magic(3)

inputData =
8     1     6
3     5     7
4     9     2

outputValues = dis(inputData);


#### Let's Examine the Output

outputValues

Why are you asking?
4     2     3
1     9     6
8     7     5


Well, that's a bit strange, isn't it? I wonder what the relationship between inputData and outputValues is. What can we learn about outputValues?

whos outputValues

  Name              Size            Bytes  Class    Attributes

outputValues      1x1               248  dis



Well, it's a dis array. Let's look at it again.

outputValues

What's it matter to you?
5     6     9
4     3     2
7     8     1


Say what? Let's check it a few more times.

outputValues
outputValues
outputValues

Who wants to know?
6     3     9
5     8     7
4     2     1
Who wants to know?
5     2     9
1     4     8
7     6     3
Who are you to ask me that?
5     3     7
9     8     2
1     4     6


Hoping you get the double meaning here - the dis array not only mixes up the values of the input for display purposes, but also tries to gently *dis*respect you along the way.

Even though this is a silly class, I'll show you the code so you can see how simple it is to make such a class.

type dis

classdef dis
%dis dis is a class.
%   In fact, it's a declasse class.

properties
Data
end
properties (Access=protected)
Original
end

properties (Constant)
'What''s it matter to you?',...
'Who are you to ask me that?',...
'Who wants to know?',...
'What''s the big deal?'}
end

methods
function display(obj)
obj.Data(:) = obj.Data(randperm(numel(obj.Data)));
disp(obj.Data)
end
function obj = dis(in)
obj.Original = in;
obj.Data = reshape(in(randperm(numel(in))),size(in));
end
end

end



#### Should We Invest More Resources?

Of course, I could also add some numeric functions like plus to dis, but I didn't take the time, in case you didn't find this possible new MATLAB addition useful. So please share your thoughts with us here.

Get the MATLAB code

Published with MATLAB® R2013a

### 15 Responses to “New Datatype under Development for Possible MATLAB Release”

1. Eric replied on :

Seems to me like it needs a Boston accent! ;)

2. Ramy Mohamed replied on :

This is April’s fools day matlab brank… Funny and cool. cheers

3. Josh Gordis replied on :

Oh no you didn’t….

4. Jiro Doke replied on :

I think we should devote at least 3 developers to this new class – One to come up with various answer phrases, one to come up with new algorithms for mixing up the values, and one to oversee the whole project.

5. Grzegorz replied on :

For me the name of class ‘dis’ is not intuitive. May be ‘fool’ is a better name?

6. Vassili replied on :

Hi Loren!
I find it interesting, because I never needed to invent new classes. To high for me.

Probably such tricks containing good portion of psychology could be used in learning, e.g. Matlab manual by a new user. Currently I learn a manual for e-fotocamera, more than 50 years after I did some white-black film fotos. I should wish me much more clear and logically structured explanations. Is DIS useful for such questions, or there are other solid and important tasks to solve with DIS ?
Best wishes
Vassili

7. Dinakar Jayarajan replied on :

Happy April Fool’s Day….But a little too obvious.

8. Peter Wittenberg replied on :

I’m sure there is some good application for these features, but I’m not planning on using them much. I suspect that there are a couple of different types of people using MATLAB. The first are the people who, like me, use MATLAB for its technical abilities. we get very familiar with functions, using the built-in ones and creating our own, and we use creatively the display functions such as plot to produce output. The second group is the programmers who will do less technical work and more software writing to come up with a good user interface and display, or ability to operate with a wide variety of inputs. It is the second group who will likely make most effective use of the new capabilities you describe. Being of the first group, I’m not likely to define classes at all, so those features are not likely useful to me. The second group is probably dying to do more object oriented programming in MATLAB and would use it. You’ll likely hear from some of them about the value of this work.

9. gerard replied on :

April fools.

10. nabinkm replied on :

Yes!
I think it is a great idea. During cross-collaboration projects, I receive .mat files with data… with no descriptions to be found… because s/he forgot to send the description files.
Hopefully this will change the issues of being able to (nicely) put descriptions on the data!!

11. nabinkm replied on :

(And I read that it was april fool’s joke?)
Remember… Gmail was launched in April 1st!
:)
The idea is good enough. Go ahead!

12. Vassili replied on :

Let me specify my question. Imagine that you are writing a computer simulation of a learning procedure, how to manage/manipulate some gadget (e.g. an e-camera) or its subset for a certain situation described in a manual.

It seems to me that DIS parameters could become a convenient general approach to program the reactions of the computer in response to pupil’s choice of one specific action out of many suggested as formally possible, but only one of them correct. At least the ability of DIS to put (possibly illuminating, too) questions feels like that. I am not sure, just a feeling.

13. Andrew Newell replied on :

Useful subclasses would be MAMA, which tells you to sit up straight; and BOSS, which tells you to stop wasting your time on this class.

14. Loren Shure replied on :

;-) to Vassili and Andrew.

15. April First replied on :

Mathworks should create a dis toolbox and blockset.

Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.

These postings are the author's and don't necessarily represent the opinions of MathWorks.