Borrar filtros
Borrar filtros

importing .txt file into matlab push button

1 visualización (últimos 30 días)
faiza
faiza el 18 de Feb. de 2015
Comentada: faiza el 18 de Feb. de 2015
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)

Respuesta aceptada

Jos
Jos el 18 de Feb. de 2015
Hi Faiza,
change
handles.fileData = fscanf(fileID,'%d');
to
temp = fscanf(fileID,'%d',[8 Inf]);
handles.fileData = temp';
That should work
  1 comentario
faiza
faiza el 18 de Feb. de 2015
It works.Thank-you Jos. Appreciate your help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by