Matlab and C/C++ communication program

hi there

I need recommendation for following scenario;

I have to write a program which  communicates between C/C++ and Matlab. C/C++ will act as server and matlab program shoul act as server. to be more specfic C/C++ program will generate
the numbers and send to the Matlab side and matlab will simultaneously plot these data.

best regards.
Who is Participating?
phoffricConnect With a Mentor Commented:
I thought you were sending the data via TCP/IP, your zone selection.
here is an m-file that communicates with a server via TCP/IP:

% MATLAB example using TCP/IP (matlab_tcpip_example.m)
% This simple code example demonstrates how you can use MATLAB to exchange data 
% with a remote application not developed in MATLAB. This code example is taken
% from a MATLAB Digest technical article written by Edward J. Mayhew from 
% George Mason University.  While HTTP was used as the higher-level protocol in 
% this example, you can use other protocols, as was the case in the project. 
% MATLAB supports TCP/IP using Instrument Control Toolbox.  Requires MATLAB and 
% Instrument Control Toolbox.  
% On line 14, substitute "" with an actual website with
% which you wish to communicate.

% Create TCP/IP object 't'. Specify server machine and port number. 
t = tcpip('', 80); 

% Set size of receiving buffer, if needed. 
set(t, 'InputBufferSize', 30000); 

% Open connection to the server. 

% Transmit data to the server (or a request for data from the server). 
fprintf(t, 'GET /'); 

% Pause for the communication delay, if needed. 

% Receive lines of data from server 
while (get(t, 'BytesAvailable') > 0) 
DataReceived = fscanf(t) 

% Disconnect and clean up the server connection. 
clear t

Open in new window

I had asked this question at work, and I was told that Matlab supports TCP communication:
and that I would have to purchase Mathworks' Instrument Control Toolbox option.

According to this link, Matlab can collect and plot data from a TCPIP server in real time.
loopfinityAuthor Commented:
Ok. thanks for links. but how can I integrated with C.
My C program will generate the numbers and write them on text files.
Matlab will interpret these numbers to plot.

could you please give solid example.
>> My C program will generate the numbers and write them on text files.
Then if your matlab can access the files directly, then you can use fscanf to read the files:
(has code examples to read file)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.