Hi,
I understand that you want to save the generated data in a structured text file. The issue is that “table” function requires column vectors as inputs. So, you should transpose x and y using x’ and y’. Also, you should change the delimiter of the “writetable” function from default delimiter “comma” to tab(“\t”) or space(“ “). To display the variable names “x” and “y”, set the “WriteVariableNames” property to “true”.
T = table(x', y', 'VariableNames', {'x', 'y'}); % Ensure column vectors
% Write table to a text file with tab delimiter
writetable(T, 'tabledata.txt', 'Delimiter', '\t', 'WriteVariableNames', true);
This will generate a text file in the desired structure.
For more information about “writetable” function, refer to the following documentation:
Thanks!
