## Loren on the Art of MATLABTurn ideas into MATLAB

Note

Loren on the Art of MATLAB has been archived and will not be updated.

# 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.

Published with MATLAB® R2013a