2
函數內我創建的代碼,這是非常有用的位從結構動態分配變量:assignin(「來電顯示」,...)在Matlab
function getParam(param)
% this function extracts the fields of structure param and assigns them
% to variables of corresponding names in the caller workspace
allFieldsParam = fieldnames(param);
for iField = 1:length(allFieldsParam)
assignin('caller',allFieldsParam{iField},param.(allFieldsParam{iField}));
end
的問題是,當我叫getParam內一個函數,有時工作,有時它返回以下形式的錯誤:
??? Error using ==> assignin
Attempt to add "blocksizes" to a static workspace.
See MATLAB Programming, Restrictions on Assigning to Variables
for details.
Error in ==> getParam at 7
assignin('caller',allFieldsParam{iField},param.(allFieldsParam{iField}));
Error in ==> classif_nmf_db at 15
getParam(param);
有人有線索,我怎麼能解決這個問題?
問候 AL
感謝這就是我一直在尋找! – titus