How to create Trignometric function lookup table
2 次查看(过去 30 天)
显示 更早的评论
Hi
I need help to create a lookup table for twiddle factor generated by trignometric cosine and sine function ?
Thanks
12 个评论
Life is Wonderful
2021-4-16
编辑:Life is Wonderful
2021-4-19
Thank you !
I was looking something like below code .
- Can you pls add further to improve say 1/4 quater radian lookup table and calculate all angles / radians ?
- What is best and efficient way for generating the lookup to get twiddle factor real and imaginary points ?
- How fft and ifft calculation can be improved here in case I use cordic sine and cosine lookup table ?
- cordiccosine and cordicsine Lookup table for N point FFT length ( say 1024,2048 upto 8192) ?
% Angle_rad = [-2*pi:1:2*pi];
close all;
clearvars;clc;
Angle_th = [0:1:360]; %
lookup_table = cos(Angle_th*2*pi/360); % replace cos with
% Replace current code here with pseudo
% What is the size of lookup table ? FFT length -1 , N = 1024, N*m-1 ( m
% =2,3,4 etc )
% cdcCosineTh = cordiccos(th_Rad_fix = [-2*pi :steps: 2*pi]);
% cdcsinTh = cordicsin(th_Rad_fix = [-2*pi :steps: 2*pi]);
% lookup_table[sizeof(FFT_Index)] = cordiccos(th_Rad_fix = [-2*pi :steps: 2*pi]) + -j*cordicsin(th_Rad_fix = [-2*pi :steps: 2*pi]);
% Which Radix 2/4/8/16/64/128/256 for odd and even is suggested and why ?
% How real and imaginary lookup table looks like
% Input real_lookup_cordiccos(angles[0:360])
% Input imag_lookup_cordicsin(angles[0:360])
% Accuracy ,performat and speed are determined by total harmonic
% distortion in -dBc i.e. SNR = rms( cordiccos & cordicsin -
% lookup_table_real & lookup_table_imag)
% It should work for iFFT and FFT implementation (reconstruct) without dC
% and capture fundamental and all harmonics for 2 octave onwards
% clf;
figure;
subplot(3,2,1);
plot(1:size(Angle_th,2),cos(Angle_th*2*pi/360),'g--','Linewidth', 1.5); hold on; grid on;
xlabel('\theta');
h1.XLim = [0, 2*pi];
h1.XTick =[0:22.5:360];
h1.XTickLabel = {'0', '45', '90','135' , '180' , '225' , '270' , '315' , '360'};
h1.YTick = -1:0.5:1;
h1.YTickLabel = {'-1.0','-0.5','0','0.5','1.0'};
title('Trignometric-Cosine-Lookup-table');
subplot(3,2,2);
plot(1:size(Angle_th,2),sin(Angle_th*2*pi/360),'r--','Linewidth', 1.5); hold on; grid on;
xlabel('\theta');
h1.XLim = [0, 2*pi];
h1.XTick =[0:22.5:360];
h1.XTickLabel = {'0', '45', '90','135' , '180' , '225' , '270' , '315' , '360'};
h1.YTick = -1:0.5:1;
h1.YTickLabel = {'-1.0','-0.5','0','0.5','1.0'};
title('Trignometric-sine-Lookup-table');
subplot(3,2,3);
radian = (pi/180)*Angle_th;
plot(Angle_th,radian,'r--'); hold on; grid on;
xlabel('\theta');ylabel('Radian');
subplot(3,2,4);
radian = (pi/180)*Angle_th;
plot(Angle_th,cos(radian),'r--'); hold on; grid on;
xlabel('\theta');ylabel('ARC');
subplot(3,2,5);
degree = (180/pi)*radian;
plot(radian,(degree),'b--'); hold on; grid on;
h1.YLim = [0, 360];
h1.YTick =[0:22.5:360];
h1.YTickLabel = {'0', '45', '90','135' , '180' , '225' , '270' , '315' , '360'};
ylabel('\theta');xlabel('Radian');
subplot(3,2,6);
degree = (180/pi)*radian;
plot(radian,cos(degree),'b--'); hold on; grid on;
ylabel('\theta');xlabel('Arc');
Walter Roberson
2021-4-16
You do not seem to be using the Fixed Point Toolbox, but you seem to be wanting to implement fixed point operations ?
Life is Wonderful
2021-4-16
That's right Walter. Initial preparation is done for floating point and next level take it to DSP :-)
The reason is to know the total harmonic distortion across the fltpt and fixpt
Walter Roberson
2021-4-16
Write it using the fixed point toolbox. One of the options for fixed point toolbox use is to override the fixed point definitions with double precision for testing purposes. And you can test in fixed point on the host CPU anyhow.
Life is Wonderful
2021-4-16
编辑:Life is Wonderful
2021-4-16
@Walter Roberson, can you please help me with some references for twiddle calculation using cordic cosine and cordic sine function?
I am assuming for calculation
twiddle(index) = cos(theta) + (1i*(sin(theta)));
Thank you!
Walter Roberson
2021-4-19
I do not know about twiddle calculation for cordic, so I would have to research it.
Walter Roberson
2021-4-19
Walter Roberson
2021-4-19
You asked for references about twiddle factor computation; I linked to a reference about twiddle factor computation.
If you had asked for a MATLAB implementation then I probably would not have posted any links. I do not have source code for that purpose, and I do not have time to research the topic and write the code.
Life is Wonderful
2021-4-20
编辑:Life is Wonderful
2021-4-20
I have some insight now . Folks have worked on this topic and there are advantage of using cordic algorithm for twiddle factor on DSP. May be MathWork documentation is poor and they should come up
With this I can write equation on a paper and start designing the code.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)