cargar archivo y usar en GUIDE
Publicado por Jordi (14 intervenciones) el 25/06/2013 17:38:40
Hola! Quiero cargar un archivo ( que son de extensión *.txt o *.data y es una matriz(solo números)) y después guardarlo en una variable X para poder usarlo en otras funciones del propio GUIDE. Lo que tengo de codigo es esto:
function Cargar_datos_Callback(hObject, eventdata, handles)
% hObject handle to Cargar_datos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName Path]=uigetfile({'*.txt;*.data;*.xls'},'Abrir documento');
if isequal(FileName,0)
return;
else
%winopen(strcat(Path,FileName));
end
handles.X=FileName;
guidata(hObject, handles);
% --- Executes on button press in PCA.
function PCA_Callback(hObject, eventdata, handles)
% hObject handle to PCA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[a,b]=size(handles.X);
%%%%%%%%%% ALGORITMO PCA %%%%%%%%%%
[COEF, SCORE, LATENTE, TSQUARED] = princomp(handles.X);
SCORE1=(SCORE(:,1));
SCORE2=(SCORE(:,2));
%%%%% Representacion vector PCA1 & PCA2
handles.g_pca=plot(handles.axes1,SCORE1,SCORE2,'*');
title('PCA')
xlabel('1ra Componente Principal')
ylabel('2da Componente Principal')
set(handles.text1,'string','El Análisis de Componentes principales consiste en encontrar transformaciones ortogonales de las variables originales para conseguir un nuevo conjunto de variables incorreladas, denominadas Componentes Principales, que se obtienen en orden decreciente de importancia.');
guidata(hObject, handles);
Que estoy haciendo mal, xq no representa lo que quiero...
function Cargar_datos_Callback(hObject, eventdata, handles)
% hObject handle to Cargar_datos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName Path]=uigetfile({'*.txt;*.data;*.xls'},'Abrir documento');
if isequal(FileName,0)
return;
else
%winopen(strcat(Path,FileName));
end
handles.X=FileName;
guidata(hObject, handles);
% --- Executes on button press in PCA.
function PCA_Callback(hObject, eventdata, handles)
% hObject handle to PCA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[a,b]=size(handles.X);
%%%%%%%%%% ALGORITMO PCA %%%%%%%%%%
[COEF, SCORE, LATENTE, TSQUARED] = princomp(handles.X);
SCORE1=(SCORE(:,1));
SCORE2=(SCORE(:,2));
%%%%% Representacion vector PCA1 & PCA2
handles.g_pca=plot(handles.axes1,SCORE1,SCORE2,'*');
title('PCA')
xlabel('1ra Componente Principal')
ylabel('2da Componente Principal')
set(handles.text1,'string','El Análisis de Componentes principales consiste en encontrar transformaciones ortogonales de las variables originales para conseguir un nuevo conjunto de variables incorreladas, denominadas Componentes Principales, que se obtienen en orden decreciente de importancia.');
guidata(hObject, handles);
Que estoy haciendo mal, xq no representa lo que quiero...
Valora esta pregunta


0