How to change the iteration value of for loop by the use of edit text box?
Show older comments
I want to get the value of iteration of 'for' loop from the user by means of edit text box in matlab gui. Is it possible? I'm unable to get output if I use handles.
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
get(handles.figure1,'SelectionType');
if strcmp(get(handles.figure1,'SelectionType'),'open')
index_selected = get(handles.listbox1,'Value');
file_list = get(handles.listbox1,'String');
filename = file_list{index_selected};
if handles.is_dir(handles.sorted_index(index_selected))
cd (filename)
load_listbox(pwd,handles)
else
[path,name,ext] = fileparts(filename);
switch ext
case '.mat'
load(filename)
handles.DE = DE;
set(handles.listbox2,'String',handles.DE)
otherwise
try
open(filename)
catch ex
errordlg(...
ex.getReport('basic'),'File Type Error','modal')
end
end
end
N = length(handles.DE);
for i = 1:handles.input
x = handles.DE((i-1)*2048+1:i*2048);
[d,TDFx(i,:)] = BHM1(x);
xd = diff(x);
[d,TDFxd(i,:)] = BHM1(xd);
xi(1)=x(1);
for j=2:length(x)
xi(j)=x(j-1)+x(j);
end
[d,TDFxi(i,:)] = BHM1(xi);
end
end
In the above code, handles.input is the numeric value which I want to get from user through edit text box.
function segments_Callback(hObject, eventdata, handles)
% hObject handle to segments (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.input = str2double(get(hObject,'String'));
guidata(hObject,'String')
This is the edit text box call back. I'm getting the error as Reference to non-existent field 'input'.
Is it possible to rectify the error? Someone please help me..
Accepted Answer
More Answers (0)
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!