필터 지우기
필터 지우기

How to apply function "strrep" to multiple substrings

조회 수: 11 (최근 30일)
Mohammad Dabbagh
Mohammad Dabbagh 2020년 9월 2일
댓글: Mohammad Dabbagh 2020년 10월 15일
Hi there,
It would be my great pleasure if anyone could assist me with the following error, caused after I applied strrep:
newIDFFile = strrep(readIDFFile, {'@@P1@@', num2str(u_gen_s)}, {'@@P2@@', num2str(u_gen_w)}, {'@@P3@@', num2str(u_gen_e)}, {'@@P4@@', num2str(u_gen_n)});
Also, I tried the following format:
newIDFFile = strrep(readIDFFile, '@@P1@@', num2str(u_gen_s), '@@P2@@', num2str(u_gen_w), '@@P3@@', num2str(u_gen_e), '@@P4@@', num2str(u_gen_n));
while the error message is:
Error using strrep
Too many input arguments.

채택된 답변

Bruno Luong
Bruno Luong 2020년 9월 2일
newIDFFile = ...
strrep( ...
strrep(...
strrep( ...
strrep(readIDFFile, ...
'@@P1@@', num2str(u_gen_s)), ...
'@@P2@@', num2str(u_gen_w)), ...
'@@P3@@', num2str(u_gen_e)), ...
'@@P4@@', num2str(u_gen_n));
  댓글 수: 2
Mohammad Dabbagh
Mohammad Dabbagh 2020년 9월 2일
Thanks! It really helped!
Mohammad Dabbagh
Mohammad Dabbagh 2020년 10월 15일
It would be also my great pleasure if you could help me with the same question, while I need to write strrep for more than 32 substrings. It shows me the following error:
Error using objective (line 2)
Error: File: building_model.m Line: 260 Column: 11
Nesting of {, [, and ( cannot exceed a depth of 32.
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by