Creating an array with constant denominators

3 visualizzazioni (ultimi 30 giorni)
Ethan Rando
Ethan Rando il 19 Nov 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]

Risposte (1)

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

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by