Clear Filters
Clear Filters

Adding semicolon and comma and saving it into .txt file

21 views (last 30 days)
I have a vector (2x6001) and I want to save it to into a .txt file,. But before saving it , I also want to add a semicolon after every even position and a comma after every odd position:
Let's say:
and I want sth like this:
How can I do this?
I don't have access to the writematrix function, only dlmwrite
I tried delimiter, but all the data will get the same delimiter.

Accepted Answer

Ildeberto de los Santos Ruiz
Try this low-level code:
x = randi(9,[1,2*6001]); % ACTUAL DATA
fileID = fopen('data.txt','w');
for k = 1:2:numel(x)-1

More Answers (0)

Community Treasure Hunt

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

Start Hunting!