Problemas con la comunicacion serial entre matlab y pic 18f

perdon por la molestia.
mi principal problema es que en matlab no me comunica con el pic, estoy realizando algo simple el encendido de dos led con botones hechos en guide, en matlab me sale es siguiente error.
?? Error using ==> serial.fopen at 72
Port: COM4 is not available. Available ports: COM1, COM2.
Use INSTRFIND to determine if other instrument objects are
connected to the requested device.

Error in ==> led>led1_Callback at 87
fopen(s);

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> led at 42
gui_mainfcn(gui_State, varargin{:});

Error in ==>
@(hObject,eventdata)led(\'led1_Callback\',hObject,eventdata,guidata(hObject))


??? Error while evaluating uicontrol Callback

adjunto el codigo en matlab

function led2_Callback(hObject, eventdata, handles)
% hObject handle to led2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
s=instrfind; %Find any serial links (we can have only 1)
delete(s); %... and delete.
clear all;
s=serial(\'COM4\');%crear puerto
set(s,\'BaudRate\',9600);%velocidad
fopen(s);%abrir puerto
fprintf(s,\'%s\',\'g\');%envio dato
fclose(s);%cerrar y eliminar puerto
delete(s);
clear s;


la simulacion en proteus si me sale, pero en la vida real no.

gracias de antemano. ...
 
Atrás
Arriba