Matlab - Ayuda para draggear matlab

 
Vista:

Ayuda para draggear matlab

Publicado por ivan (24 intervenciones) el 20/08/2012 13:41:49
Hola

Vereis estoy terminando mi proyecto final de carrera y he llegado a una parte un poco escabrosa, resulta que tengo un "axes" donde se muestra una señal de audio, y sobre esa señal de audio tengo que poder draggear, esto es que pueda seleccionar partes de la grafica y suprimirlas o moverlas a otro lado, para ello tengo este codigo:

function [P1 P2] = Posicion_Lineas(data)

Pos1=get(data.LineaMin, 'XData');
Pos2=get(data.LineaMax, 'XData');

if Pos1>Pos2

dum=Pos2;
Pos2=Pos1;
Pos1=dum;

end;

P1=floor(Pos1(1).*data.fs_original)+1;
P2=floor(Pos2(1).*data.fs_original)+1;

Y por otro lado tengo este otro:

function varargout = pitch_main(varargin)
% PITCH_MAIN M-file for pitch_main.fig
% PITCH_MAIN, by itself, creates a new PITCH_MAIN or raises the existing
% singleton*.
%
% H = PITCH_MAIN returns the handle to a new PITCH_MAIN or the handle to
% the existing singleton*.
%
% PITCH_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PITCH_MAIN.M with the given input arguments.
%
% PITCH_MAIN('Property','Value',...) creates a new PITCH_MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before pitch_main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to pitch_main_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 pitch_main

% Last Modified by GUIDE v2.5 06-Sep-2011 19:04:29

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pitch_main_OpeningFcn, ...
'gui_OutputFcn', @pitch_main_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 pitch_main is made visible.
function pitch_main_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 pitch_main (see VARARGIN)

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



% Update handles structure
guidata(hObject, handles);

if strcmp(get(hObject,'Visible'),'off')
initialize_gui(hObject, handles);
end

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


% --- Outputs from this function are returned to the command line.
function varargout = pitch_main_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;


function initialize_gui(fig_handle, handles)

data.M=[];
data.indice_alg=1;%indice para el text box de algoritmo.
data.init=0; %para ver si ya se ha cargado algun archivo
data.recalc_silencios=1;
data.silencios.te='auto';
data.hps.Armlimit=0.01; %limite para HPS
datahps.ceps=0;
data.hps.Armax=0;
data.hps.whit=1;
% data.solape=50;
% data.N=1024;

setappdata(fig_handle, 'data', data);
%
% set(handles.edit9, 'String', data.L);
% set(handles.edit11, 'String', data.solape);
% set(handles.edit27, 'String', data.N);




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

% Hints: get(hObject,'String') returns contents of edit_nombre_wav as text
% str2double(get(hObject,'String')) returns contents of edit_nombre_wav as a double


% --- Executes during object creation, after setting all properties.
function edit_nombre_wav_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_nombre_wav (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in Boton_Cargar.
function Boton_Cargar_Callback(hObject, eventdata, handles)
% hObject handle to Boton_Cargar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

data = getappdata(gcbf, 'data');


if data.init==1

PathName=data.PathName;


[FileName, PathName, filterindex] = uigetfile( {'*.wav', 'Archivo PCM WAV(*.wav)';'*.aiff', 'Archivo AIFF(*.aiff)'; ...
'*.au','Archivo AU(*.au)';'*.*', 'Todos los Archivos(*.*)'},'Selecciona un archivo de audio',PathName);


else



[FileName, PathName, filterindex] = uigetfile( {'*.wav', 'Archivo PCM WAV(*.wav)';'*.aiff', 'Archivo AIFF(*.aiff)'; ...
'*.au','Archivo AU(*.au)';'*.*', 'Todos los Archivos(*.*)'},'Selecciona un archivo de audio');


end;


if ~isequal(FileName,0) && ~isequal(PathName,0) %SI SE HA ELEGIDO UN ARCHIVO VáLIDO....

% close(Configurar_Silencios);
% close(Configurar_Analisis_Espectrograma);
% close all;

data.init=1;
data.recalc_silencios=1;
data.PathName=PathName;

[PATHSTR,NAME,EXT,VERSN] = fileparts([PathName FileName]);


switch lower(EXT)

case '.wav'

[x,fs,nbits]=wavread([PathName FileName]);

case '.aiff'

[x,fs,nbits]=aiffread([PathName FileName]);
x=x./32768;
nbits=max(nbits);
case '.au'

[x,fs,nbits]=auread([PathName FileName]);
otherwise

errordlg('Formato no soportado','Error');
return;

end;

siz=size(x);

if siz(2)==2

x=sum(x,2)./2;

end;

%Parte de datos

% data = getappdata(gcbf, 'data');

%Configuración de la señal
data.x=x;
data.fs_original=fs;
data.fs=fs;
data.nbits=nbits;

%Configuración de la ventana


data.L=fix((1024/44100)*fs);
data.Lseg=data.L/fs;

data.Solape=50;
data.w=hamming(data.L);
data.Solape_M=floor((1-(data.Solape/100))*data.L);






set(handles.edit_VENTANA_L, 'Enable', 'off');
set(handles.edit_VENTANA_L, 'String', data.L);

set(handles.edit_VENTANA_Lseg, 'Enable', 'off');
set(handles.edit_VENTANA_Lseg, 'String', fix(data.L/fs*100000)/100);

set(handles.edit_VENTANA_SOLAPE, 'Enable', 'on');
set(handles.edit_VENTANA_SOLAPE, 'String', data.Solape);


set(handles.popupmenu_VENTANA_TIPO, 'Enable', 'on');
set(handles.popup_VENTANA_LSEG, 'Enable', 'on');


%Configuración de algoritmos de Estimación de pitch

data.fmin=50;
data.fmax=2000;

if data.fmax>data.fs/2
data.fmax=data.fs/2;
end;

set(handles.edit_fmin, 'Enable', 'on');
set(handles.edit_fmax, 'Enable', 'on');

set(handles.edit_fmin, 'String', data.fmin);
set(handles.edit_fmax, 'String', data.fmax);


set(handles.Boton_Algoritmo_Analisis, 'Enable', 'on');
set(handles.popupmenu_Algoritmo_Tipo, 'Enable', 'on');
set(handles.Boton_Ejecutar_Transcripccion, 'Enable', 'on');




%INICIALIZACION DE ALGORITMOS

%HPS
data.hps.Armlimit=0.01; %limite para HPS
data.hps.ceps=0;
data.hps.Armax=0;
data.hps.whit=1;













%CONFIGURACION DE ESPECTROGRAMA

data.espectrograma.N=fix((1024/44100)*fs);
data.espectrograma.L=fix(((1024/44100)*fs)/2);
data.espectrograma.solape=50;






set(handles.edit_nombre_wav, 'String', FileName);


data.filename=FileName;
set(handles.edit_FS, 'String', fs);

%set(handles.edit_FS, 'Enable', 'on');

set(handles.Boton_Reproducir, 'Enable', 'on');
set(handles.Boton_Salvar, 'Enable', 'on');
set(handles.Boton_Analisis, 'Enable', 'on');
set(handles.popupmenu_Analisis, 'Enable', 'on');

set(handles.Toggle_Silencios, 'Enable', 'on');
set(handles.Toggle_Silencios, 'String', 'Activar');
set(handles.Toggle_Silencios, 'Value',0);
set(handles.Boton_Configurar_Silencios, 'Enable', 'off');

set(handles.Boton_Ejecutar_Transcripccion, 'Enable', 'on');

set(handles.Boton_Configurar_Transcripcion, 'Enable', 'off');


%Configuracion de silencios

data.ite=floor((length(data.x))/(data.L-data.Solape_M+1));
data.silencios.silpos=ones(data.ite+1,1);
data.silencios.Cuadro=0;
data.silencios.LineaMin=0;



%Parte Gráfica
setappdata(gcbf, 'data', data);

plot_axes1(data,handles);

end;



ESTE CODIGO ESTA INCOMPLETO, DEBIDO A QUE NO PUEDO PONERLO ENTERO AQUI, SI ALGUIEN ESTA INTERESADO QUE ME AVISE Y LE MANDO EL SCRIPT COMPLETO.

Estos codigos me los dieron de otro proyecto, con lo que en teoria se supone que deben de funcionar pero por mas que los pruebo no consigo nada, si alguien sabe otra forma de dragear...

Saludos y gracias
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
Imágen de perfil de Dave
Val: 497
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Ayuda para draggear matlab

Publicado por Dave (1094 intervenciones) el 22/08/2012 06:18:54
Hola Iván;

Los fragmentos de código que colocas son un poco extensos para revisarlos en el foro, quizás sería mejor si los colocas en algún sitio desde donde, la persona interesada en revisar tu código pueda descargar tu código.

Saludos
Dave Correa
[email protected]
Servicios de Programación Matlab
http://fismatlab.blogspot.com/
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

Ayuda para draggear matlab

Publicado por ivan (24 intervenciones) el 22/08/2012 20:16:15
Creo que esa parte no tiene archivo .fig, sino que iba dentro de otro, es lo que creo, debido a que es el codigo que me dieron en la universidad para que lo examinara y consiguiera la obcion de dragear mis señales, de todas formas buscare haber si puedo encontrar el .fig
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
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Ayuda para draggear matlab

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 23/08/2012 21:09:51
la funcion fileparts solo admite como argumento de salida:3 datos .
por eso esta parte falla
[PATHSTR,NAME,EXT,VERSN] = fileparts([PathName FileName]);

lo correcto es:
[PATHSTR,NAME,EXT] = fileparts([PathName FileName]);

Alli si le puede ejecutar el codigo que haz puesto en el foro.


Saludos.
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
programador en matlab
Servicios de programacion matlab
[email protected]

http://matlabcaballero.blogspot.com
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

Ayuda para draggear matlab

Publicado por ivan (24 intervenciones) el 23/08/2012 21:30:03
Creo que eso da mas o menos igual, si te fijas en la ayuda de matlab al poner "help fileparts" al pinchar sobre el doc, te muestra que puede llevar 4 argumentos de entrada.
Pero a pesar de eso en la parte en la que estoy interesado es en la de poder dragear sobre una grafica, es decir poder trabajar directamente sobre la grafica.

Si alguien lo necesita o esta interesado en el codigo completo, que me avise o me notifique su correo y le envio el proyecto completo para que lo vea.

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
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Ayuda para draggear matlab

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 23/08/2012 21:41:04
fileparts


Parts of file name and path



Note The fourth output argument of fileparts (file version) is no longer supported and has been removed. Calling the function with more than three output arguments generates an error.
Syntax



[pathstr, name, ext] = fileparts(filename)




Description


[pathstr, name, ext] = fileparts(filename) returns the path name, file name, and extension for the specified file. The file does not have to exist. filename is a string enclosed in single quotes. The returned ext field contains a dot (.) before the file extension.
Tips


fileparts only parses file names. It does not verify that a file or a folder exists.

You can reconstruct the file from the parts using:
fullfile(pathstr,[name ext])


On Microsoft Windows systems, you can use either forward (/) or back (\) slashes as path delimiters, even within the same string. On UNIX and Macintosh systems, use only / as a delimiter. You can use the filesep function to insert the correct separator character for the platform on which your code executes:
sep = filesep;
file = ['H:' sep 'user4' sep 'matlab' sep 'classpath.txt'];

file =
H:\user4\matlab\classpath.txt


If the input consists of a folder name only, be sure that the right-most character is a delimiter (/ or \). Otherwise, fileparts parses the trailing portion of filename as the name of a file and returns it in name instead of in pathstr.
Input Arguments


filename

String containing a name of a file or folder, which can include a path and file extension. The function interprets all characters following the right-most delimiter as a file name plus extension.
Output Arguments


pathstr

String containing the part of filename interpreted as a path name

name

String containing the name of the file without any extension

ext

String containing the file extension only, beginning with a period (.)
Definitions

Path Name


The full or partial path to a destination folder location, always the initial portion of the filename string. Path names end with a slash character and, where appropriate, can begin with a drive letter. Windows paths use backward slashes (\). UNIX and Macintosh paths use forward slashes (/).
Examples


Return the pieces of a file specification string to the separate string outputs pathstr, name, and ext. The full file specification is:
file = 'H:\user4\matlab\classpath.txt';
[pathstr, name, ext] = fileparts(file)

pathstr =
H:\user4\matlab

name =
classpath

ext =
.txt


Query parts of a user .cshrc file:
[p,n,e] = fileparts('/home/jsmith/.cshrc')

pathstr =
/home/jsmith

name =
Empty string: 1-by-0

ext =
.cshrc



fileparts interprets the entire file name as an extension because it begins with a period



Saludos.
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
programador en matlab
Servicios de programacion matlab
[email protected]

http://matlabcaballero.blogspot.com
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

Ayuda para draggear matlab

Publicado por julio alejandro (1 intervención) el 13/05/2015 06:35:49
Buenas noches, quisiera saber si aun tienes el codigo completo, y pudieras proporcionarmelo al siguiente correo [email protected],muchas gracias de antemano
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