Create and save a table
34 views (last 30 days)
Show older comments
Vittorio Faustinella
on 17 Nov 2021
Answered: Cris LaPierre
on 17 Nov 2021
How can i create and save a table from a multiple result of a function?
I used this command to print result on a file.dat
fprintf(fid1,' _______________________________________________________________________ \n');
fprintf(fid1,'r(m) b(r,t)(m) P(r,t)(Pa) r^2/t (m^2/s) Sw\n');
fprintf(fid1,' ________________________________________________________________ \n');
fprintf(fid1,'%15.2f %15.6f %15.6e %15.6e %12.4f\n',r,b_r,P,Sim,S_w)
and I've something like this
________________________________________________________________________
r(m) b(r,t)(m) P(r,t)(Pa) r^2/t (m^2/s) Sw
________________________________________________________________________
0.30 70.000000 2.068816e+07 2.853881e-09 0.3000
0.60 70.000000 2.060942e+07 1.141553e-08 0.3000
0.90 70.000000 2.056336e+07 2.568493e-08 0.3000
.... ........ ........ ........ ......
but i want the same result on a table .xls (for example) or .mat
Thanks for your help.
0 Comments
Accepted Answer
Cris LaPierre
on 17 Nov 2021
Since you already have the variables defined, I would create a variable of data type table.
varnames = ["r(m)" "b(r,t)(m)" "P(r,t)(Pa)" "r^2/t (m^2/s)" "Sw"];
r = [0.3 0.6 0.9]';
b_r = [70 70 70]';
P = [2.068816e7 2.060942e7 2.056336e7]';
Sim = [2.853881e-9 1.141553e-8 2.568493e-8]';
S_w = [.3 .3 .3]';
% create a table
T = table(r,b_r,P,Sim,S_w,'VariableNames',varnames)
0 Comments
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!