I'm trying to take 4 sensor signals from Arduino to Matlab. The signals are read until the user decides to end the process (a button on the App). The signal comes into Matlab as a string where it is then split (0.1,0.2,0.4,0.5,1.2 to 0.1 0.2 0.4 0.5 1.2).
I'll try to condense the code to just one signal. I keep getting the "Index exceeds matrix dimensions" error. My code is also running very slow, so any tips on this would be greatly appreciated.
My Arduino code is fine. It's running as a switch case: when 's' is sent, the signal is read; when 'd' is sent, the program jumps out of that Arduino loop and no longer sends the signal. Without Matlab, it outputs exactly what I need it to.
Programs: MATLAB R2017a, App Designer, Arduino 1.8.2
Matlab App Code:
counter = 1;
app.EndTest = 0;
app.S1 = zeros(1, app.timer);
array1 = zeros(1, app.timer);
while app.EndTest == 0
data = fscanf(app.s, '%s');
IncomingString = split(data, ',');
app.S1 = IncomingString(1);
arrayString1 = str2double(app.S1);
app.S1EditField.Value = arrayString1;
S1Time = arrayString1(counter);
app.realGraph = plot(app.RealTimeAxes,timeData, arrayString1, 'b');
counter = counter + 1;
I have this code for 4 sensors (basically it just repeats everything four times). I know this code will not be able to copy and paste because it's in App Designer, but if you see anything that could help that would be awesome.
Thanks ahead of time!