Creating an array with constant denominators
1 view (last 30 days)
Show older comments
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]
0 Comments
Answers (1)
Shiva Kalyan Diwakaruni
on 23 Nov 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:
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!