Reading file from GUI edit text
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
donga
2012년 9월 10일
0 개 추천
댓글 수: 1
Meryem
2014년 9월 22일
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...
카테고리
도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!