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개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

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