Changing from logarithmically spaced

I currently have a function which gives me center frequencies, but I want to change the chape to be more like the attached. What I have right now is similar to this but flipped, how can I change my code to give me center frequencies shapes like the image? Thank you for your time!
fs = 20e3;
numFilts = 32; %
filter_number = 5;
order = 4;
CenterFreqs = logspace(log10(50), log10(8000), numFilts);
figure
plot(CenterFreqs)
title('Center Frequncies')

답변 (2개)

Mann Baidi
Mann Baidi 2024년 2월 28일
편집: Mann Baidi 2024년 2월 28일

0 개 추천

Hi,
As per the information provided, I can understand that you would like to shape your graph same as the shape of image shared. I would suggest you to plot the data of the 'CenterFreqs' by multiplying it -1 and plot the graph in the -ve -axis. So, basically plotting the mirror image w.r.t the origin (0,0). You can use this modified code:
fs = 20e3;
numFilts = 32;
filter_number = 5;
CenterFreqs = logspace(log10(50), log10(8000), numFilts);
plot(CenterFreqs)
title('Original Graph')
figure
CenterFreqs=-1*CenterFreqs; % Mirror image w.r.t to x-axis
plot(-1:-1:-32,CenterFreqs) % Mirror image w.r.t to y-axis
title('Desired Graph')
Hoping this will help in resolving the issue!
Dyuman Joshi
Dyuman Joshi 2024년 2월 29일

0 개 추천

fs = 20e3;
numFilts = 32;
filter_number = 5;
order = 4;
CenterFreqs = logspace(log10(50), log10(8000), numFilts);
figure
plot(CenterFreqs, 'DisplayName', 'Original Plot')
hold on
%flipping x and y values accordingly
plot(flip(1:numel(CenterFreqs)), max(CenterFreqs)-CenterFreqs, 'DisplayName', 'Modified Plot')
title('Center Frequncies')
legend('Location', 'best')

댓글 수: 5

The shape is now correct, but I use center frequencies later so I do not want to change just the plot I want to also change the values. I tried this, but the shape is incorrect, how could I modify this?
fs = 20e3;
numFilts = 32; %
filter_number = 5;
order = 4;
CenterFreqs = logspace(log10(50), log10(8000), numFilts);
CenterFreqs=flip(1:numel(CenterFreqs));
figure
S
S 2024년 3월 4일
Sorry, but I don't understand what you meant to say.
Do you want to get the values of the flipped/mirrored plot?
Then use this -
flipx_values = flip(1:numel(CenterFreqs));
flipy_values = max(CenterFreqs)-CenterFreqs;
Dyuman Joshi
Dyuman Joshi 2024년 3월 26일
Any updates, @S?
S
S 2024년 3월 27일
@Dyuman Joshi Yes so if I want to resave these flipped y values under centerfreqs, I could just do
CenterFreqs=flipy_values because when I do this it messes up the rest of my script when it should just be the reverse of the original CenterFreqs

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

S
S
2024년 2월 28일

댓글:

S
S
2024년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by