1
這與How to retrieve local variables?有關,但範圍更廣。是否有可能通過matlab函數來自動比較函數中局部變量的值?
該場景看起來像這樣。假設我有兩個功能
function [OutA OutB OutC] = F1 (x,y,z)
local1 = x + y - z %some arbitrary computation
local2 = x - y + z %other computation
end
function [OutA OutB OutC] = F2 (x,y,z)
local1 = x+ y %some computation
local2 = x - y %other computation
end
我想編寫,將採取F1 F2 x y z "local1" "local2"
作爲輸入的功能,和每一個與輸入x y z
執行期間返回1
如果local1
在F1
與F2
的local2
匹配。
是否可以在Matlab中完成此操作,理想情況下無需修改原始功能? 我猜這是關於函數是否是Matlab中的第一類對象的問題,我嘗試Google但未找到它。