How about matlab size function ?

Why is the size of matrix b different from the size of matrix a?
Please, any suggestions? How to fix it
________________________
a = testSizeFunction
a =
1×1 testSizeFunction array with properties: s: [2×3 double]
[M,N] = size(a)
M = 2
N = 3
b = rand(size(a))
b = 2×2
0.5167 0.2590 0.8186 0.9810

 Accepted Answer

Matt J
Matt J on 4 Mar 2023
Edited: Matt J on 4 Mar 2023
You have not overloaded the size method appropriately for the case where nargout=1:
a = testSizeFunction;
siz=size(a)
siz = 2
Try this instead:
function varargout = size(obj,varargin)
[varargout{1:nargout}] = builtin('size', obj.s, varargin{:}); % call builtin size function
end

6 Comments

Thank you very much
You're welcome, but please Accept-click the answer to indicate that it worked.
Thank you very much, it works.
I'm glad, but please Accept-click the answer.
Okay. It works well.
@Mohamed Gharbi: Please click the "Accept This Answer" button on Matt J's answer.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2022b

Tags

Asked:

on 4 Mar 2023

Commented:

on 5 Mar 2023

Community Treasure Hunt

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

Start Hunting!