Creating an array with constant denominators

1 visualización (últimos 30 días)
Ethan Rando
Ethan Rando el 19 de Nov. de 2020
Respondida: Shiva Kalyan Diwakaruni el 23 de Nov. de 2020
Hi I have a set of signal of cos() functions and I would like to reformat them based off of their period. I would just like to adapt the original signal to be in the form of
(num) / den
How do I combine the num and den arrays so that the output stays in the form of
(X2 * 2 * p) / d
Below is the code, again I would just like a final array output that is
[(3*2*pi)/60 (20*2*pi)/60 (28*2*pi)/60]
clc
clear all
x=cos(540*pi*t) + cos(3600*pi*t) + cos(5040*pi*t);
A = sym([(540*pi)/5400, (3600*pi)/5400, (5040*pi)/5400]);
X = gcd(A)
X2 = A ./ X
[n, d] = numden(X)
n = n * 2
d = d * 2
num = X2 * n
den = [d d d]

Respuestas (1)

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni el 23 de Nov. de 2020
Hi,
For the output to stay in the format (X2 * 2 * p) / d . You can use the displayFormula function from Symbolic Math toolbox.
%Your Code
A = sym([(540*pi)/5400, (3600*pi)/5400, (5040*pi)/5400]);
X = gcd(A)
X2 = A ./ X
[n, d] = numden(X)
n = n * 2
d = d * 2
num = X2 * n % change this line to >>displayFormula(“X2*n/d”)
Hope it helps.
References:

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by