Using Two Expressions together in factor()

1 view (last 30 days)
Could anyon ehelp em with this as I am getting the below mentioned error while using two expressions together in the factor() function. Thanks
syms x y
factor([x^2-y^2,x^3+y^3])
Error using sym/factor (line 51)
First argument must be scalar.
  2 Comments
Ehsan Wadood
Ehsan Wadood on 2 Mar 2021
Thank you for your response however I expect an output, like this:
[ (x - y)*(x + y), (x + y)*(x^2 - x*y + y^2)]

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Mar 2021
syms x y
f = arrayfun(@factor, [x^2-y^2,x^3+y^3], 'uniform', 0);
vertcat(f{:})
ans = 

More Answers (0)

Community Treasure Hunt

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

Start Hunting!