how to send 10 digit from matlab to arduino.

we have to send the 10 digit phone number from matlab to arduino and then to gsm for sending a message. but the arduino is not getting the phone number from matlab. the program of matlab and arduino is attached herewith.

matlab code for the given purpose is:

function varargout = sms(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @sms_OpeningFcn, ...
'gui_OutputFcn', @sms_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

% --- Executes just before sms is made visible.
function sms_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = sms_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
global arduino; % initiating arduino as variable
try
arduino = serial('COM4','BaudRate',9600); % Start Serial communication with arduino at port 12 with baudrate 57600
fopen(arduino);

catch e
obj = instrfind; % execute when there is an error
fclose(obj);
delete(obj); % delete object
i=0;
arduino = serial('COM4','BaudRate',9600); % recreate arduino variable
fopen(arduino);
end

function num_Callback(hObject, eventdata, handles)
A = str2double(get(hObject,'String'));

% --- Executes on button press in sms.
function sms_Callback(hObject, eventdata, handles)
global arduino
fprintf(arduino,'@');
fprintf(arduino,A);

gui of matlab and arduino code is given in the attachments

gsm_send_sms_matlab.ino (564 Bytes)

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

The technique in the 3rd example will be the most reliable.

...R

Useless to show Matlab code as we don't program in Matlab here.

If you want help with Matlab code post your question on the Mathworks forums.

.

            arduino = serial('COM4','BaudRate',9600);                    % Start Serial communication with arduino at port 12 with baudrate 57600

That comment is complete nonsense.

Ive changed the com port when running, but forgot to change it int he command.