Hi all,
I'm very very unfamiliar with MATLAB. I've been trying to write a code that can neatly organize the data that is stored in certain variables into a text file.
What I want the final product to look like is this:
Each column is stored in separate variables (e.g. nodeID=[1;2;3;4], X=[0;0;120;120], etc)
I've been trying to use frpintf function and got to where there is a breakline between the column titles and the numbers.
I'd like to know how to evenly space these numbers as shown in the picture. Currently I've been adding spaces (using ' ') via fprintf but this gives me something that looks like below:
the code i have is the following (it's embarrassing really):
here nNode = 4,
for i = 1:nNode
fprintf(txt,'\n');
fprintf(txt, '%d', nodeID(i));
fprintf(txt, ' ');
fprintf(txt, '%.2f', X(i));
fprintf(txt, ' ');
fprintf(txt, '%.2f', Y(i));
fprintf(txt, ' ');
fprintf(txt, '%.3f', fx(i));
fprintf(txt, ' ');
fprintf(txt, '%.3f', fy(i));
end
Is there a more efficient way to go about this issue?
Thanks a bunch 🙂
Best Answer