Overload mtimes for double*char
이전 댓글 표시
I am working on a Matlab class that handles numbers/matrices with physical units. I would like the user to be able to write the input as (double)*(char), like this:
L = 10*’m’ % L is ten meters long
This operation calls the mtimes function for the double class. I can easily overload this function and make it work as I want with respect to (double, char)-input, but I still want it to work normally for (double, double)-input. Using * inside the mtimes function with (double, double)-input simply refers the function back to itself, resulting in an infinite regression.
Can I modify the original double mtimes function, or how do I go about this?
Thanks
채택된 답변
추가 답변 (2개)
Matt J
2013년 1월 30일
0 개 추천
You should define your own char class (e.g., mychar) with its own mtimes method.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!