thesiswork
Student
- Feb 8, 2022
- 11
Hello,
I want to create a txt file from matlab. Here's the txt file I want to create and attaching the matlab code as well. You can use any dummy matrix instead of values1
% random numbers for data to write to text file:
str(1) = "TABLED1";
data1 = [str(1) 2001];
% data2 = values;
A = values((1:4),(1:3));
% open the file for writing:
fid = fopen('test_output.txt','w');
% write each value as an 8-character-wide floating-point number, followed by
% a space; after every 10 such columns of values, write a newline (\n):
fprintf(fid,'%s %g\n',data1);
fprintf(fid,'%s',"+");
for i = 1:4
for j = 1:3
fprintf(fid,[repmat('%8.3f',i,10) ' \n'],A.');
% if repmat(A(1,>9)) %If the data exist from 9th column than it should have '+' sign in 10th column
% fprintf(fid,'%s',"+");
% end
end
end
% close the file:
fclose(fid);
I want to create a txt file from matlab. Here's the txt file I want to create and attaching the matlab code as well. You can use any dummy matrix instead of values1
% random numbers for data to write to text file:
str(1) = "TABLED1";
data1 = [str(1) 2001];
% data2 = values;
A = values((1:4),(1:3));
% open the file for writing:
fid = fopen('test_output.txt','w');
% write each value as an 8-character-wide floating-point number, followed by
% a space; after every 10 such columns of values, write a newline (\n):
fprintf(fid,'%s %g\n',data1);
fprintf(fid,'%s',"+");
for i = 1:4
for j = 1:3
fprintf(fid,[repmat('%8.3f',i,10) ' \n'],A.');
% if repmat(A(1,>9)) %If the data exist from 9th column than it should have '+' sign in 10th column
% fprintf(fid,'%s',"+");
% end
end
end
% close the file:
fclose(fid);