Arduino to Matlab - save data in vector / array
hey guys,
does know how store serial data coming matlab in array? new matlab , getting dimension error whenever enter code:
s = serial('com10');
fopen(s)
for = 1 : 1000,
v(i) = fscanf(s);
end
fclose(s)
delete(s)
clear s
thanks
does know how store serial data coming matlab in array? new matlab , getting dimension error whenever enter code:
s = serial('com10');
fopen(s)
for = 1 : 1000,
v(i) = fscanf(s);
end
fclose(s)
delete(s)
clear s
thanks
fscanf reads available data when call it, it's reading more 1 value @ time. if type "doc fscanf" it'll show you can add arguments specify how many values read.
assuming you're printing ascii characters arduino, looks want use fscanf(s, %d, 1) if you're reading integers, or fscanf(s,%f,1) if you're reading floats.
you v = horzcat(v, fscanf(s)), append data read fscanf() v. you have make sure v has @ least 1 value before call horzcat, cant concatenate onto empty matrix. and if fscanf returns data in columns instead of rows, might have use vertcat instead.
assuming you're printing ascii characters arduino, looks want use fscanf(s, %d, 1) if you're reading integers, or fscanf(s,%f,1) if you're reading floats.
you v = horzcat(v, fscanf(s)), append data read fscanf() v. you have make sure v has @ least 1 value before call horzcat, cant concatenate onto empty matrix. and if fscanf returns data in columns instead of rows, might have use vertcat instead.
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Arduino to Matlab - save data in vector / array
arduino
Comments
Post a Comment