필터 지우기
필터 지우기

Creating an array with constant denominators

조회 수: 4 (최근 30일)
Ethan Rando
Ethan Rando 2020년 11월 19일
답변: Shiva Kalyan Diwakaruni 2020년 11월 23일
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
Shiva Kalyan Diwakaruni 2020년 11월 23일
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에서 Numbers and Precision에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by