Display numeric value before function with using syms

1 visualización (últimos 30 días)
David Cole
David Cole el 2 de En. de 2024
Comentada: Dyuman Joshi el 12 de En. de 2024
How can I force the numeric part of my function to display first?
syms t;
u=symunit;
current = vpa(0.002*sin(10^3*t));
displayFormula("i=current*u.A")

Respuesta aceptada

Karl
Karl el 2 de En. de 2024
You can include the unit when you define current:
syms t;
u=symunit;
current = vpa(0.002*sin(10^3*t))*u.A;
displayFormula("i=current")
  1 comentario
Dyuman Joshi
Dyuman Joshi el 12 de En. de 2024
I have accepted this answer, as it accurately provides the expected output.

Iniciar sesión para comentar.

Más respuestas (1)

Hassaan
Hassaan el 2 de En. de 2024
Editada: Hassaan el 2 de En. de 2024
syms t;
u = symunit; % Define symbolic unit system
current = vpa(0.002*sin(10^3*t)); % Create a symbolic expression
% Append the unit
formattedCurrent = current*u.A;
% Display the formatted current with the unit
disp(formattedCurrent);
The variable current now holds a high-precision symbolic representation of the function 0.002*sin(1000*t). This expression has not been numerically evaluated because t is still a symbolic variable without a specific value.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems
  • Electrical and Electronics Engineering

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by