Symbolic Toolbox: "error using replace"

In version 2025b:
syms a b c x
f = a*x^2+b*x+c
f = 
gives error message:
Error using replace
Too many input arguments
This used to work fine (at least up to version 2023a, I also noted the issue in version 2024b).
Any idea what's going wrong anyone?

댓글 수: 9

Works fine here in 2025b Update 1. Can you copy/paste the entire error message (all of the red text) as in edit to your question or in a repsonse to this comment?
matlabRelease
ans =
matlabRelease with properties: Release: "R2025b" Stage: "release" Update: 1 Date: 05-Sep-2025
syms a b c x
f = a*x^2+b*x+c
f = 
Henri
Henri 2025년 10월 29일
Thanks Paul. Here is the entire error message:
Error using replace
Too many input arguments.
Error in
allstrs = replace(allstrs, char(1), "
"); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error in sym/display>displayVariable (line 97) disp(value,novars) ^^^^^^^^^^^^^^^^^^ Error in sym/display (line 58) displayVariable(namestr,X,symSuggestions,true); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@Henri, I'm not sure what you did, but I attempted to create a situation that leads to the error.
syms a b c x
f = a*x^2+b*x+c
f = 
str1 = char(f);
str2 = "x";
str3 = "y";
% normal
f = replace(str1, str2, str3)
f = 'c + b*y + a*y^2'
% abnormal
f = replace(str1, str2, str3, 1)
Error using replace
Too many input arguments.
Stephen23
Stephen23 2025년 10월 29일
편집: Stephen23 2025년 10월 29일
At first glance it looks like the wrong REPLACE is being called by the symbolic display routine.
Please show the complete output of this command:
which replace -all
/MATLAB/toolbox/matlab/strfun/replace.m replace is a built-in method % string method replace is a Java method % java.lang.String method /MATLAB/toolbox/matlab/testframework/unittest/core/+matlab/+unittest/+plugins/+plugindata/ResultDetails.m % matlab.unittest.plugins.plugindata.ResultDetails method replace is a Java method % java.util.HashMap method replace is a Java method % java.util.AbstractMap method replace is a Java method % java.util.Map method replace is a Java method % java.util.Collections$UnmodifiableMap method /MATLAB/toolbox/matlab/bigdata/@tall/replace.m % tall method /MATLAB/toolbox/mbc/mbclayouts/@xregcontainer/replace.m % xregcontainer method /MATLAB/toolbox/mbc/mbcview/@cgddnode/replace.m % cgddnode method /MATLAB/toolbox/parallel/array/distributed/@codistributed/replace.m % codistributed method
Henri
Henri 2025년 10월 29일
C:\Program Files\MATLAB\R2025b\toolbox\matlab\strfun\replace.m % Shadowed
replace is a built-in method % string method
C:\Program Files\MATLAB\R2025b\toolbox\matlab\bigdata\@tall\replace.m % tall method
C:\Program Files\MATLAB\R2025b\toolbox\mbc\mbclayouts\@xregcontainer\replace.m % xregcontainer method
C:\Program Files\MATLAB\R2025b\toolbox\mbc\mbcview\@cgddnode\replace.m % cgddnode method
C:\Program Files\MATLAB\R2025b\toolbox\parallel\array\distributed\@codistributed\replace.m % codistributed method
Does it work if you use "replace" outside the symbolic environment ?
What do you get from the critical command
z = replace('fsdds''fsfd',char(1),"")
z = 'fsdds'fsfd'
?
Henri
Henri 2025년 10월 29일
Error using replace
Too many input arguments.
Torsten
Torsten 2025년 10월 29일
편집: Torsten 2025년 10월 29일
I'm confused.
The usual MATLAB "replace" function seems to be shadowed by another function "replace" with the same name, but this shadowing function is not listed in your output from
which replace -all
Do you know of a function with name "replace.m" that you've created and that is saved somewhere on your MATLAB path ?
Walter Roberson
Walter Roberson 2025년 10월 29일
편집: Walter Roberson 2025년 10월 29일
What shows up if you command
dbtype 'C:\Program Files\MATLAB\R2025b\toolbox\matlab\strfun\replace.m' 1:3
Also, try
which replace('ab','a','c')

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

답변 (1개)

Henri
Henri 2025년 10월 30일
이동: Walter Roberson 2025년 10월 31일

0 개 추천

@Torsten Hopp indeed, another replace.m in my Matlab path, that's embarrassing having warned students about this kind of thing for the last 35 years... So, all sorted. Thank you all for your contributions!

카테고리

제품

릴리스

R2025b

질문:

2025년 10월 29일

이동:

2025년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by