2
我有一個m文件函數,我想用這個文件將2個函數句柄和6個浮點數傳遞給主文件。我試圖將所有8包含到數組中並從m文件函數中輸出,但這不起作用。有沒有辦法做到這一點?在函數輸出中傳遞多個函數句柄
我有一個m文件函數,我想用這個文件將2個函數句柄和6個浮點數傳遞給主文件。我試圖將所有8包含到數組中並從m文件函數中輸出,但這不起作用。有沒有辦法做到這一點?在函數輸出中傳遞多個函數句柄
您可以創建函數句柄或雙精度數組,但爲了創建一個既包含函數句柄又包含雙精度值的數組,您需要使用cell array。不推薦,因爲索引和調用之間的模糊性的功能手柄
function output = myFunction(someInput)
%# create handle1, handle2, numbers 1-6
%# ...
%# assemble output:
%# output{1} contains the first handle
%# output{3} contains the first number
%# output{6} contains an array of numbers 4 through 6
output = {handle1, handle2, number1, number2, number3, [number4, number5, number6]};
陣列 - 事實上,最近MATLAB的版本甚至沒有讓您連接函數處理成一個陣列,每個HTTP:// WWW。 mathworks.com/help/techdoc/ref/function_handle.html – Edric