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 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

タグ

質問済み:

2023 年 3 月 4 日

コメント済み:

2023 年 3 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by