Matlab - GUI Listbox

 
Vista:

GUI Listbox

Publicado por Angela (4 intervenciones) el 06/03/2014 09:14:18
Hola a todos y gracias de antemano.

Estoy haciendo una GUI en Matlab y quiero que seleccionar un valor en una listbox y que ese valor se exporte a un archivo excel cuando pase a la siguiente "pantalla".

Lo había hecho así, pero no me funciona:

function RFuente1_Callback(hObject, eventdata, handles)
% hObject handle to RFuente1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
index_selected = get(hObject,'Value');
index_selected_texto=get(hObject, 'String');
handles.RFuente1=index_selected_texto;
guidata(hObject, handles);

function Siguiente_Callback(hObject, eventdata, handles)
% hObject handle to Siguiente (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

RFuente1= handles.RFuente1;

A={'Fuente';RFuente1};
xlswrite('situacion.csv',A,'B1:B2');

clear,clc,close all

D16;


Muchas gracias a todos,

Ángela
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

GUI Listbox

Publicado por Angela (4 intervenciones) el 06/03/2014 19:35:12
Hola a todos,

Al final lo he hecho de otra manera porque lo que quería hacer en realidad es muy sencillo y no tenía por qué complicarme tanto.

function varargout = fuentes(varargin)
% FUENTES M-file for fuentes.fig
% FUENTES, by itself, creates a new FUENTES or raises the existing
% singleton*.
%
% H = FUENTES returns the handle to a new FUENTES or the handle to
% the existing singleton*.
%
% FUENTES('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FUENTES.M with the given input arguments.
%
% FUENTES('Property','Value',...) creates a new FUENTES or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before fuentes_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to fuentes_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help fuentes

% Last Modified by GUIDE v2.5 06-Mar-2014 19:17:09

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @fuentes_OpeningFcn, ...
'gui_OutputFcn', @fuentes_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before fuentes is made visible.
function fuentes_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to fuentes (see VARARGIN)

% Choose default command line output for fuentes
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes fuentes wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = fuentes_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
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)
estado = get(handles.fuente1,'Value');
if estado==1

A={'Fuentes'; 'Fuente 1'};
xlswrite('prueba.csv',A,'B1:B2');
end

estado = get(handles.fuente2,'Value');
if estado==1

A={'Fuentes'; 'Fuente 2'};
xlswrite('prueba.csv',A,'B1:B2');
end

clear,clc,close all



Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar