How to create .dat file using matlab

55 views (last 30 days)
PRASHIK GAIKWAD
PRASHIK GAIKWAD on 29 Sep 2018
Answered: Adam Danz on 30 Sep 2018
%% Given data begin = 1; step = 10; end_data = 100; n1 = begin:step p1 = isprime(n1) n1(p1) data = p1; save 'myfile.dat' data -ascii load myfile.dat

Answers (1)

Adam Danz
Adam Danz on 30 Sep 2018
Here's a low-level method customized to your variable data which is a logical vector that gets written to file myfile.dat'.
fid = fopen('myfile.dat', 'w');
fprintf(fid, '%d ', data);
fclose(fid)
For more information on this method and how to format the data, see

Categories

Find more on Structures 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!