You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to create Trignometric function lookup table
4 views (last 30 days)
Show older comments
Hi
I need help to create a lookup table for twiddle factor generated by trignometric cosine and sine function ?
Thanks
12 Comments
Life is Wonderful
on 16 Apr 2021
Edited: Life is Wonderful
on 19 Apr 2021
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
on 16 Apr 2021
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
on 16 Apr 2021
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
on 16 Apr 2021
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
on 16 Apr 2021
Edited: Life is Wonderful
on 16 Apr 2021
@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
on 19 Apr 2021
I do not know about twiddle calculation for cordic, so I would have to research it.
Walter Roberson
on 19 Apr 2021
Walter Roberson
on 19 Apr 2021
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
on 20 Apr 2021
Edited: Life is Wonderful
on 20 Apr 2021
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.
Answers (0)
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)