フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Construct an object given another object of that class

1 回表示 (過去 30 日間)
Matthias Schabel
Matthias Schabel 2011 年 4 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
What I want to do can be accomplished with the following :
classdef X methods function obj = X(x) obj.x = x; end
function y = f(obj,x)
y = eval([class(x) '(' num2str(-x.x) ')']);
end
end
properties
x;
end
end
a = X(2); b = a.f(a);
but the use of eval is ugly and slow. Is there not a better way to get the class of an object from the object itself?
Matthias

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by