Hey guys,
Does anyone know how to store the serial data coming into matlab in an array? I am completely new to matlab and I am getting a dimension error whenever I enter this code:
fscanf reads all available data when you call it, so it's probably reading more than 1 value at a time. if you type "doc fscanf" it'll show you that you can add arguments to specify how many values to read.
Assuming you're printing ascii characters with the Arduino, it looks like you want to use fscanf(s, %d, 1) if you're reading integers, or fscanf(s,%f,1) if you're reading floats.
You could also do something like v = horzcat(v, fscanf(s)), which will append however much data you read from fscanf() to v. You just have to make sure v has at least one value before you call horzcat, you cant concatenate onto an empty matrix. And if fscanf returns data in columns instead of rows, you might have to use vertcat instead.