Reading file from GUI edit text
Show older comments
hi all,
I making gui that exams wav files, I want to write the file name in the gui edit text and to get the file details, the file is in my matlab dircetory
here is my code
% --- Executes during object creation, after setting all properties.
function file_input_CreateFcn(hObject, eventdata, handles)
% hObject handle to file_input (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in file_analyze.
function file_analyze_Callback(hObject, eventdata, handles)
% hObject handle to file_analyze (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%starting analyzing Function!!!!
name = str2double(get(handles.file_input,'String'));
[y, Fs] = wavread('name');
Y=fft(y,512);
m=Y.*conj(Y)/512;
f=Fs*(0:256)/512;
t=0:1/Fs:(length(y)-1)/Fs;
%Createing frequency Plot
axes(handles.frequency_axes)
plot(f,m(1:257))
i geting the error:Invalid Wave File. Reason: Cannot open file.
Accepted Answer
More Answers (1)
donga
on 10 Sep 2012
0 votes
1 Comment
Meryem
on 22 Sep 2014
Hi all,
I want to write the file name in the gui edit text and save edit text as my filename. Than I could be able to save filename as I wish. For instance; My file is an Neural network file which could be save as *.mat file; here is my code
%network_name is my edit text
name = get(handles.network_name,'string');
name = net;
save name
But it doesn't work I can't manage file name from edit text :(
It saves as name that l wrote next to save (name.mat). Thanks for your any answer...
Categories
Find more on Environment and Settings 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!