필터 지우기
필터 지우기

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

조회 수: 11 (최근 30일)
MD REZWANUR RAHMAN
MD REZWANUR RAHMAN 2021년 6월 28일
답변: Chunru 2021년 6월 28일
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 '-'.

답변 (1개)

Chunru
Chunru 2021년 6월 28일
% 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);

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by