Format output with constant display values

2 visualizaciones (últimos 30 días)
Ethan Rando
Ethan Rando el 19 de Nov. de 2020
Respondida: Fangjun Jiang el 19 de Nov. de 2020
Hello, how would I format this code so that it has an output display of
(2*pi*X2)/period
Where the displayed output is not simplified and the denominator is always period (60) and the numerator is always displayed as 2*pi*_.
Basically I want the format to be the same but only the X2 value to change, no simplification.
fs = 5400;
T = 1/fs;
n = 0:959; %sample 960
t = n * T;
xn = 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];
period = d; %60
pretty((2*pi*X2)/period);

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 19 de Nov. de 2020
%%
X2=5.6;
period=60;
fprintf('2*pi*%g/%g\n',X2,period);

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by