Avoid multiple output using fprintf of multiple variables in livescript
Show older comments
My script is:
k=[3.96306869127352e-05;
1.33047441644794e-05;
3.37761112449900e-05;
7.19380417629400e-06];
confk=[2.95622613104490e-05;
6.38219462217362e-06;
1.15227436682386e-05;
8.98428923906260e-05];
formatSpec = 'k1=%4.2e +/- %8.3e;\n';
f1=fprintf(formatSpec,k(1),confk(1));
formatSpec = 'k2=%4.2e +/- %8.3e;\n';
fprintf(formatSpec,k(2),confk(2));
formatSpec = 'k3=%4.2e +/- %8.3e;\n';
fprintf(formatSpec,k(3),confk(3));
formatSpec = 'k4=%4.2e +/- %8.3e;\n';
fprintf(formatSpec,k(4),confk(4));
Even if it works that way, what I want is that it comes out one output and not one for each. I tried this way:
formatSpec='k=%4.2e +/- %8.3e\n';
fprintf(formatSpec,k,confk)
But so they don’t come out "k1,k2,k3,k4". I also tried with a for cycle but nothing done.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Report Generator 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!