dialog box option instead of the input command
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello
Here is a piece my code which takes an input file for analysis. The file itself(asig) has 10 million rows and two columns. The following input commands take the limits to scan the data.
[anasignal,path] = uigetfile('*.csv','Select the .csv file to analyze');
if isequal(anasignal,0)
disp('User selected Cancel');
end
asig = csvread(fullfile(path, anasignal),15,0);
llimit = input('specify where you want to start panning?:');
ulimit = input('specify where you want to end panning?:');
aamp = asig(llimit:ulimit,2);%vary this to get more samples
ts = asig(2,1) - asig(1,1);%sampling rate calculated automatically
tim = [llimit-1:ulimit - 1]*ts;%vary this in accordance with aamp
time = tim';%transposed to get a column vector for plotting
Input command takes me to Matlab command prompt. Is there a way to get a dialog box/modal window instead which takes two values lower limit and upper limit and assigns it to llimit and ulimit?
Thanks
0 comentarios
Respuesta aceptada
Paulo Silva
el 24 de Ag. de 2011
prompt = {'Enter ulimit:','Enter llimit:'};
dlg_title = 'Enter the limits';
num_lines = 1;
def = {'1','2'}; %default values for the inputs
answer = inputdlg(prompt,dlg_title,num_lines,def);
ErrStatus=0;
if isempty(answer)
disp('User canceled the input')
ErrStatus=1;
else
if (strcmp(answer{1},'') | strcmp(answer{2},'')) %empty strings
disp('Error: Empty inputs not allowed')
ErrStatus=1;
else
ulimit=str2num(answer{1});
llimit=str2num(answer{2});
end
end
if isempty(ulimit) | isempty(llimit) %empty array
disp('Error: Empty inputs not allowed')
ErrStatus=1;
end
%you might also need to verify the size of the inputs
if numel(ulimit)>1 | numel(llimit)>1 %empty array
disp('Error: Arrays not allowed')
ErrStatus=1;
end
%more verifications needed, values outside the range or zero
if ~ErrStatus %values are good to be used
%insert your code here
ulimit
llimit
end
0 comentarios
Más respuestas (1)
Walter Roberson
el 24 de Ag. de 2011
It is possible to program such a thing, but it would not be considered good style as it would involve a called routine assigning values in the workspace of the caller.
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!