Borrar filtros
Borrar filtros

why get a symbolic result in the workspace ?

2 visualizaciones (últimos 30 días)
Stanley Cheng
Stanley Cheng el 22 de En. de 2014
Respondida: Walter Roberson el 22 de En. de 2014
Hi everyone,
I run a matlab code containing symbolic variables in it. When I use "subs" code to substitute all of the symbolic variables in a variable with numerical values, after computation, I obtain a symbolic format result of the variable in the workspace in matlab. but when i use findym() to check which symbolic variable in it, I find no symbolic ones exist in it. just as the following for instance for brevity because my code is too long:
syms a b;
c=a+b;
d=subs(c,[a,b],[1,2]);
normally d should be a numerical value, but it is symbolic
It is quite strange.
Could anyone give a reason for this? Thanks so much for your help!

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de En. de 2014
subs() converts numeric values into symbolic form and does the substitution in symbolic form giving a symbolic answer. The symbolic answer might possibly only contain numbers and constants such as Pi and operations on these, and so might completely represent a specific numeric value -- or the symbolic answer might be approximatible as a specific numeric value (e.g., it might have been calculated in more digits than fit into a MATLAB numeric value.)
To convert a symbolic representation of a number into a MATLAB numeric representation, apply double() to the symbolic form.

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by