sending 'result' as an input to a function
1 回表示 (過去 30 日間)
古いコメントを表示
Hi!
I want to ask whether it is possible to send 'result ' clause as input to a function;
I have this code:
if antall_salter_tilgjengelige==3
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';' HCOONa'; 'CaBr2'};
str={'Choose the salts available'};
result=listdlg('Promptstring',str, 'ListSize', [100,100], 'ListString', S, 'SelectionMode', 'multiple');
% everything that comes below here ,
% I want that segment to be a part of a function
% instead of having it at the same place as the code written above.
% The question is then whether I can send ''result'' as an input to a function...
if all(ismember(result,[1 2 3 ]))
forste_saltet=result(1,1);
andre_saltet=result(1,2);
tredje_saltet=result(1,3);
0 件のコメント
回答 (1 件)
Image Analyst
2021 年 11 月 21 日
The answer is yes.
if antall_salter_tilgjengelige==3
S={'NH4Cl'; 'MgCl2'; 'CaCl2'; 'KCl'; 'ZnSO4'; 'NaCl'; 'ZnBr2'; 'CH3CO2K';'HCOOK';' HCOONa'; 'CaBr2'};
str={'Choose the salts available'};
result=listdlg('Promptstring',str, 'ListSize', [100,100], 'ListString', S, 'SelectionMode', 'multiple');
% everything that comes below here ,
% I want that segment to be a part of a function
% instead of having it at the same place as the code written above.
% The question is then whether I can send ''result'' as an input to a function...
otherResults = myFunction(result)
end
%=======================================================================================
function otherResult = myFunction(result)
otherResult 0; % Whatever you want to return...
if all(ismember(result,[1 2 3 ]))
forste_saltet=result(1,1);
andre_saltet=result(1,2);
tredje_saltet=result(1,3);
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Construct and Work with Object Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!