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!