Hi Andrea,
I understand that you are trying to use the “mldivide” operator on quantized values. The result you get is a vector of double values because “mldivide” is designed to work with only 3 data types. They are as follows:
In this case when you use the “quantize” function to quantize the matrices “A” and “b”, the output you get is still a matrix of doubles, just the values have been quantized. MATLAB doesn’t create a special datatype for the quantized values.
If you want to create a special data type for the quantized variables, you can use the "fi" function from the Fixed Point Designer toolbox. Here's an example:
A_fixed = fi(A, true,h, k);
b_fixed = fi(b, true,h, k);
This will create variables named as “A_fixed” and “b_fixed” which will be of type “embedded.fi”, which is a fixed-point data type. The “mldivide” function cannot work with this data type and will throw an error like below:
Arguments must be numeric, char, or logical.
The “mldivide” function is optimized to work with double precision floating point values, hence the result you get is a vector of doubles. Even if you use quantized values in all the preceding steps of your calculation, the “mldivide” operation will operate only with numeric values You would have to quantize the result after the “mldivide” operation to get your desired quantized result.
Refer to the below documentation links for more information:
- “mldivide” function: https://www.mathworks.com/help/matlab/ref/mldivide.html?s_tid=doc_ta#btg5qam-2
- The “fi” function: https://www.mathworks.com/help/fixedpoint/ref/embedded.fi.html
- The “quantize” function: https://www.mathworks.com/help/fixedpoint/ref/embedded.fi.quantize.html
I hope this helps.