Creating an array with constant denominators

2 次查看(过去 30 天)
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]

回答(1 个)

Shiva Kalyan Diwakaruni
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:

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by