MATLAB: Matlab.ui.control.Table append column to new line of text file with space delimiters

MATLABtext fileuitable

Hi Guys,
I really need help with this.
I have a UITable in App Designer with 3 columns. Column 1 contains a counter for the number of rows, column 2 contains a number between 100 and 500, and column 3 contains a decimal number between 0 and 1.
I need to get the contents of column 2 and append it in a new line of a text file in a row with space delimeters. For example:
Text File:
196 196 294 294 329 329 294 262 262 247 247 220 220 196 294 294 262 262 247 247 220 294 294 262 262 247 247 220 196 196 294 294 329
247 247 262 294 294 262 247 220 196 196 220 247 247 220 220 247 247 262 294 294 262 247 220 196 196 220 247 220 196 196 220 220 247 196 220 247 262
Text file after appended data from column 2:
196 196 294 294 329 329 294 262 262 247 247 220 220 196 294 294 262 262 247 247 220 294 294 262 262 247 247 220 196 196 294 294 329
247 247 262 294 294 262 247 220 196 196 220 247 247 220 220 247 247 262 294 294 262 247 220 196 196 220 247 220 196 196 220 220 247 196 220 247 262
220 196 294 220 247 247 196 220 220 247 196 247 247 262
I also need to do the same thing for column 3 aswell, I imagine the code will look very similar.
Thank you so much for your help.

Best Answer

Lets say the handle of your UI table is uit,
To get ui table data
D=get(uit,'Data');
Now you have the data from the table in variable ā€˜Dā€™
fileId=fopen('krishna.txt','w') %to create a new text file
fprintf(fileId,'\n');
fprintf(fileId,'%d',D(:,3)); %To print third column