new column of data in Serial Monitor

hello,

in arduino serial monitor, I acquire three columns of different data seperated with tab "Serial.print("\t"); "
If I read that data in Matlab, it doesn't recognise those data as three columns, but one.

is there any "Serial.print("???")" that helps to write each data in next column, that Matlab will be able to recognise it as next column?

thanks

You will have to provide more detail. For example, are you using regexp?

I frequently use tab as separator. In general it's a good choice for text data.

IIRC matlab uses a ; or a , as default separator. Try one of those

Can you post your matlab code?
And Arduino code ?

Hello,

this is one part of arduino code

Serial.print("\t");
  Serial.print(freq(), DEC);
  Serial.print("\t");
  Serial.print("");   
  Serial.print(osvet(), DEC);
  Serial.println("\t");

it gives me this results on Serial Monitor (where the left column is counter), and the other two columns are other data

1 	800	86956	
2 	800	86956	
3 	790	85869	
4 	790	85869	
5 	780	84782	
6 	780	84782	
7 	780	84782	
8 	780	84782	
9 	780	84782	
10 	790	85869

Ok, now I want to read this in Matlab

s = serial('COM4', 'BaudRate', 9600);
fopen(s);

for i= 1:2000

data=fscanf(s);
y(i)=str2double(data);
plot(i,y(i));
drawnow;
hold on
end
fclose(s);

but I want to plot third column (y), and first coulmn (x)...
actually I want to do that:

.
.
.
plot(data(:,1),data(:,3);
drawnow;
.
.
.

so, is it possible, and how?

thank you for your help!!!

Try this...

  data=fscanf( s, '%d %d %d', 3 );

I tried, but it doesn't work...it doesn't read third column... :frowning:

as I know, arduino writes results as "string", so I wrote this code in Matlab:

data=fscanf( s, '%s',3 )
y(i)=str2double(data)
plot(i,y(i));

drawnow;
hold on

ok, it gives me something, but it is not correct... :confused:

and another question: How can I connect dots in "real time" graph in Matlab? I have discrete measurments, and it plot me only seperated points...

Why are you using single quotes around strings? In C, at least, single quotes are for characters, and double quotes are for strings.

if i look at this - Read data from text file - MATLAB fscanf - MathWorks Benelux -

% Create a file with an exponential table
x = 0:.1:1;
y = [x; exp(x)];

fid = fopen('exp.txt', 'w');
fprintf(fid, '%6.2f %12.8f\n', y);
fclose(fid);

% Read the data, filling A in column order
% First line of the file:
%    0.00    1.00000000

fid = fopen('exp.txt');
A = fscanf(fid, '%g %g', [2 inf]);
fclose(fid);

% Transpose so that A matches
% the orientation of the file
A = A';

looks like you miss the fid ?