Writing into .txt file

1 回表示 (過去 30 日間)
Griffin Polglaze
Griffin Polglaze 2020 年 7 月 12 日
回答済み: Vladimir Sovkov 2020 年 7 月 12 日
I have currently created two separate matrices both [500x1] and am trying to write them into one .txt file but it is not working. If anyone could give suggestions, it would be appreciated.
close all
clear all
M = 500;
D = 0.05;
angl_min = pi;
angl_max = 2*pi;
p = rand(M,1);
angle_random = angl_min + ((angl_max - angl_min).*p);
v = (D/2)*ones(M,1);
fp = fopen('random_cylind.txt','w+');
for i = 1:M
fprintf(fp,'%2.25f\t%2.25f\n',v,angle_random);
end
fclose(fp);

採用された回答

Vladimir Sovkov
Vladimir Sovkov 2020 年 7 月 12 日
T = [v angle_random]; % this is if you want a 2-column file
save('random_cylind.txt','T','-ascii','-double'); % explore available options for "save" in Matlab documentation

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by