How to apply function "strrep" to multiple substrings

8 ビュー (過去 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.
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 9 月 2 日
The syntax is in "doc strrep".

サインインしてコメントする。

採用された回答

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 Center および File ExchangeWhos についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by