필터 지우기
필터 지우기

importing .txt file into matlab push button

조회 수: 1 (최근 30일)
faiza
faiza 2015년 2월 18일
댓글: faiza 2015년 2월 18일
I am new to matlab. I have a text file of size [66553*8].I am trying to import the file in Matlab gui using push button.But when I do that the size of the file changes to [532424*1].Why is it happening.
I have one push button ,one checkbox.I am trying to import the .txt file using push button and then plotting the data of txt file using my checkbox.This is my relevant code:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.txt'},'Open Directory');
if isequal(filename,0) || isequal(pathname,0)
return
end
fileID = fopen(fullfile(pathname, filename));
handles.fileData = fscanf(fileID,'%d');
guidata(hObject, handles);
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
handles.fileData
x=handles.fileData
xa = x(:,3)
plot(xa)

채택된 답변

Jos
Jos 2015년 2월 18일
Hi Faiza,
change
handles.fileData = fscanf(fileID,'%d');
to
temp = fscanf(fileID,'%d',[8 Inf]);
handles.fileData = temp';
That should work
  댓글 수: 1
faiza
faiza 2015년 2월 18일
It works.Thank-you Jos. Appreciate your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by