How can I save the information generate in the script below which include strings and table in the following format to a text file?
Format:
M=5
1 21
2 22
3 23
4 24
5 25
5points
Script:
clc;
clear all;
close all;
ElmentsNum = "EM=5";
x = (1:5)';
y =(21:25)';
t = table(x,y);
M = "5points"
fileID = fopen('E:/Data.txt');
fprintf(fileID,'%s/n',ElmentsNum)
fprintf(fileID,'%.4f',t)
fprintf(fileID,'%s/n',M)
fclose(fileID)
clear allis very seldomly necessary.clearby itself clears all variables from the workspace, and is what you are attempting to do.clear allalso unloads all previously loaded function definitions, meaning that they will all be loaded again when you use them, slowing down your code.