How to send information after compilation to Matlab

09 Oct 2011

Hi,

I'm using mBed as a processor to compute an equation and send back those arguments to MATLAB. So MATLAB reads from mBed those parameters passed on.

The coding done is shown below:-

#include <stdio.h>

#include <iostream> 
#include <ctime> 
#include <cstdlib> 
#include <math.h>
#include <time.h>

#include "mbed.h"



using namespace std; 
int main(){ 
       
  srand( (unsigned)time( NULL ) );
        
  double myarr[10]; 
        
 int gen =0;
 double Ab1;
 double Ab2	;

 int xmax = 2;
 int xmin = -2;
 
 int ymax = 2;
 
 int ymin = -2;

	  

 while(gen < 300){
	 for(int i = 0; i < 10; i++) {
  myarr[i] = (double) rand()/(double) RAND_MAX; 
 Ab1 = (xmax + myarr[i]*(xmin-xmax))/2;
       
	 }
 printf("%.4f ",Ab1);

for(int j = 0; j < 10; j++){
	   myarr[j] = (double) rand()/(double) RAND_MAX; 
 Ab2 = (ymax + myarr[j]*(ymin-ymax))/2;
 }
 printf("%.4f ",Ab2);	 
 gen++;
	 }
 getchar();

}

I just want to send the Ab1 and Ab2 values to MATLAB where it this values will be plot out.