1

I have two programs. one is reading some data from UR5 robot while the other is reading data from a sensor. I need to collect these data into a table as I carry out some industrial task.

I was able to generate table for each program when they were separate but I need to create one MAIN program which calls the functions and is to combine these tables together. Now I only get one line of what I need. Here is my Main program below:

idleForces = Thesis_calibration();
Time_Stamp = [];
while (true)
timestring = datestr(now,'HH:MM:SS.FFF');
[~,~,~,hours,minutes,seconds] = datevec(timestring);
time_ms = 1000*(3600*hours + 60*minutes + seconds);

measuredForces = Thesis_acquisition();
ur5Data = UR5_CLIENT_new();
Forces = minus(measuredForces,idleForces);

Row = table(time_ms,ur5Data);
Force = table(Forces);
writetable(Row,'robotdata.csv','Delimiter',',')

pause(0.01);
end

The output is found in this picture. How can I make it to store line by line? DATA WRITTEN TO THE CSV FILE

1 Answers1

1

Instead of writetable use dlmwrite and just enter your data as a matrix. Important bit is the '-append' or it will just overwrite column 1 the same as with writetable.

newRow = [time_ms,ur5Data];
dlmwrite('robotdata.csv',newRow,'-append');

The default delimiter is ',' so you don't need to worry about that. Though you can set the delimiter in the dlmwrite function if you choose.

user3376851
  • 149
  • 10