How to export data from C ++ to MatLab

I wrote a C ++ program that displays a list of random numbers. I was asked to export these numbers to MatLab to create a histogram and other graphics. How can i do this? (I am new, specify additional files and steps that I need to add). Thank.

+5
source share
2 answers

Here is what I did from matlab console ( input.txtcontains 3 integer values):

>> f=fopen('input.txt','rt')

f =

     3

>> fscanf(f,'%d')

ans =

        1234
       23435
         888

>> fclose(f)

ans =

     0

>> 

Summarizing:

f=fopen('input.txt','rt');
integerList = fscanf(f,'%d');
fclose(f);

More about the features you can use doceither helpin the Matlab console:

doc fscanf
help fscanf
+2
source

. , , Matlab 1-D, load.

+1

All Articles