Azzera filtri
Azzera filtri

Replace '+-" with '-' in a csv file

11 visualizzazioni (ultimi 30 giorni)
MD REZWANUR RAHMAN
MD REZWANUR RAHMAN il 28 Giu 2021
Risposto: Chunru il 28 Giu 2021
I have some data file in .csv format. In the data there are complex values like 3+-3i, but I want to replace all of this '+-' with '-'.

Risposte (1)

Chunru
Chunru il 28 Giu 2021
% Read data
fid = fopen('yourfile.csv');
s = fscanf(fid, '%c', [1 inf]); % read all text from file
fclose(fid);
% Replace string
s = strrep(s, '+-', '-');
% Save data
fid = fopen('newfile.csv');
s = fprintf(fid, '%c', s); % read all text from file
fclose(fid);

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by