假设我有以下代码:
%%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