MATLAB: Importing .txt file into matlab push button

push buttontxt

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)

Best Answer

Hi Faiza,
change
handles.fileData = fscanf(fileID,'%d');
to
temp = fscanf(fileID,'%d',[8 Inf]);
handles.fileData = temp';
That should work