0
假設我有以下代碼:需要幫助的澄清MATLAB的輸入對話框的
%%input dialog box%%%
prompt = {'Enter gain:','Enter range:'};
dlg_title = 'Enter values';
num_lines= 1;
def = {'20','256'}; %default
answer = inputdlg(prompt,dlg_title,num_lines,def);
%%%to get the two entered values%%%%
A = getfield(answer,{1}); %first input field
A = str2double(A);
B = getfield(answer,{2}); %second input field
B = str2double(B);
是什麼意思用「與結構,而不是getfield
動態字段名」?
如何在輸入值複雜且小於零的情況下使用循環,從而向用戶請求其他兼容輸入?
我試過下面的循環,但它不起作用。爲什麼?
while isnan(A) || ~isreal(A) || A<0
prompt = {'Enter gain:'%'Enter range:'};
dlg_title = {'undefine!!'};
num_lines= 1;
def = {'',''}%{'20','256'}; %default
answer = inputdlg(prompt, dlg_title, num_lines, def);
A = getfield(answer,{1}); %first input field
A = str2double(A);
%A = str2double(input('Enter the value of module(mm) : ', 's'));
end
我不是很清楚與循環你能提供更具體的例子,則返回true ?非常感謝你@slayton – green