How about matlab size function ?

4 次查看(过去 30 天)
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

采纳的回答

Matt J
Matt J 2023-3-4
编辑:Matt J 2023-3-4
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 个评论
Voss
Voss 2023-3-5
@Mohamed Gharbi: Please click the "Accept This Answer" button on Matt J's answer.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by