MATLAB Answers

MWArray: Non-conventional-Matlab terminology for data types and arrays?

5 views (last 30 days)
FM
FM on 23 Oct 2020
Commented: Todd Flanagan on 29 Oct 2020
As far as I know, and based on the thread "scalar vs matrix vs vector vs array??", a double array in Matlab is an array of type double. A scalar is a single-element array, so the number of dimensions is irrelevant. An array can have any number of dimensions, some of which may have zero size.
The above meanings of double and scalar seem to differ from the "MWNumericArray" documentation:
MWNumericArray(boolean rVal, boolean iVal, MWClassID classid)
Constructs a complex numeric double array that represents the
primitive boolean arguments.
MWNumericArray(boolean rVal, MWClassID classid)
Constructs a real scalar numeric array that represents the
primitive boolean argument.
MWNumericArray(byte rVal)
Constructs a real scalar numeric array of type MWClassID.INT8
that represents the primitive byte argument.
MWNumericArray(byte rVal, byte iVal)
Constructs a complex scalar numeric array of type
MWClassID.INT8 that represents the primitive byte arguments.
In the first function call, what is meant by "complex numeric double array"? Is it a single-element array, with the 1 element using a double for the real part and a double for the imaginary part? Shouldn't the precision be determined by the "classid" argument?
Unlike the first call, the second function call returns a "real scalar numeric". Why is the word "scalar" used here but not in the first call? Is "scalar" being used differently from Matlab to mean non-complex?
If that is the case, then why is the 4th function call also described as returning "complex scalar numeric array)?
AFTERNOTE: Finding even more undefined terminology as I try to reference the information more. For example, the `getDouble` method sometimes returns a "1-based index-array as a double". The internet doesn't seem to return a meaning for "index-array" in the context of Java. (After much mulling & digging: "Index" probably refers to the purpose of the array rather than how the array is realized. Such an array of length "n" contains the coordinates of a single element in an n-dimensional array)

Accepted Answer

Todd Flanagan
Todd Flanagan on 29 Oct 2020
Edited: Todd Flanagan on 29 Oct 2020
MWNumericArray(boolean rVal, boolean iVal, MWClassID classid)
This signature will take Java booleans and convert them to classid in MATLAB. There are Java signatures for all of the supported Java types like boolean, int8, double, etc.
boolean r = false;
boolean i = true;
MWNumericArray a = new MWNumericArray(r, i, MWClassID.LOGICAL);
In this case, if classid is "logical", there will be no conversion.
If classid is double, you will get a double array in MATLAB.
boolean r = false;
boolean i = true;
MWNumericArray a = new MWNumericArray(r, i, MWClassID.DOUBLE);
  2 Comments
Todd Flanagan
Todd Flanagan on 29 Oct 2020
Hi,
I see what you are saying now.
Constructs a complex numeric double array that represents the primitive boolean arguments.
Should read somthing like:
Constructs a complex scaler numeric array that represents the primitive boolean arguments.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by