fprintf Command Script Calling
显示 更早的评论
for i = 1:5
fprintf ('1 |%8.2f|%16.8f| % 20.16e| /n', x);
end
Here is the script I have so far. I am calling a script and x is a variable in another script I am calling into this one. Variable x is an array of variables generated randomly. With what I have reproduced so far I need five rows, numbered with a different output. My current output lookes like this:

I want five rows total not including the header row that mimic the first row where it begins: 1 | -38.35 | .... All of the rows will have random numbers except the first column which I am trying to get 1:5 (1 through 5). So the second row should begin: 2 | 75.61 | ... and so on to 5 | ---- |... Thank you!
回答(2 个)
Walter Roberson
2022-2-17
for i = 1:5
fprintf ('%d |%8.2f|%16.8f| % 20.16e| /n', i, x);
end
x = randn(1,3);
for i = 1:5
fprintf('%d |%8.2f|%16.8f| % 20.16e| \n', i, x);
end
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!