Common factor

Is there a function to make it find a common factor in an expression with symbolic variables?
For example:
ab+ac--(matlab command)--->a(b+c)
Thanks

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 29 de Sept. de 2011

0 votos

help factor
syms a b c
factor(a*c + b*c)

6 comentarios

cyberdyne
cyberdyne el 29 de Sept. de 2011
I've tried that but it worked one time only....now returns me the error:
Error using==>subsindex
Function 'subsindex' is not defined for values of class 'sym'
How is it possible?
Walter Roberson
Walter Roberson el 30 de Sept. de 2011
Did you happen to define a new factor.m ? Try
which factor
cyberdyne
cyberdyne el 3 de Oct. de 2011
No. The error returns if I use 'factor' funcion in command window while editor runs.
A bug?
Walter Roberson
Walter Roberson el 3 de Oct. de 2011
I haven't heard of that one before. Does that include if the editor is up but showing no files at all ?
Zoya Saevna
Zoya Saevna el 3 de Feb. de 2021
You shouldn't be kidding!
Steven Lord
Steven Lord el 22 de Abr. de 2024
I know this part of the discussion is kind of old, but that error message cyberdyne quoted is likely to occur if for example the user were to store the output of the call to the factor function to a variable named factor in the Command Window. [Though it appears the text of the error message may have changed in the decade+ since the original message.]
syms a b c
f = a*b+a*c
f = 
factor = factor(f) % This first call works
factor = 
z = factor(f) % This second one does not, since factor is now a variable
Error using indexing (line 918)
Invalid MATLAB indexing or symbolic function definition. Symbolic function arguments must be symbolic variables and function body must be convertible to sym expression.

Error in indexing (line 962)
R_tilde = builtin('subsref',L_tilde,Idx);

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 29 de Sept. de 2011

Comentada:

el 22 de Abr. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by