MATLAB Answers

convert complex number to Integers

13 views (last 30 days)
Jogger
Jogger on 11 May 2021
Commented: Jogger on 29 Sep 2021
I have a exponential function and cordic exponential function.
I see a differenc in output for exponential and cordic exp func
Example -
theta = [-pi:pi/4:pi]
y = exp(theta)
y1 = cordiccexp(theta)
cordic exponential works only for complex number where as exponential works for complex and real/integer numbers
Question - How to (Mathematics) get cordiccexp out same as exponetial function

Answers (2)

KSSV
KSSV on 11 May 2021
Edited: KSSV on 11 May 2021
cordicexp calculates
cos(theta)+i*sin(theta)
To make cordicexp and exp same you need to use:
exp(i*theta)
Remember Euler's formula.
exp(i*x) = cos(x)+i*sin(x)
  3 Comments
Jogger
Jogger on 11 May 2021
I need below and not imaginary of cordic exponential.
theta = [-pi:pi/4:pi];
y = cos(theta)+i*sin(theta);
y1 = cordiccexp(theta); % imaginary
y2 = exp(theta); % no imaginary
figure;
subplot(2,1,1);plot(1:length(y),real(y1),'r--','linewidth',2.5); hold on; grid on;legend('cordicexp');
subplot(2,1,2);plot(1:length(y),real(y2),'b--','linewidth',2.5); hold on; grid on;legend('exponential');

Sign in to comment.


VBBV
VBBV on 28 Sep 2021
Try with cordicsincos function to get more closely matching outputs
theta = [-pi:pi/4:pi];
y = cos(theta)+i*sin(theta);
y1 = cordicsincos(theta); % imaginary
y2 = exp(1i*theta); % no imaginary
figure;
subplot(2,1,1);plot(1:length(y),real(y1),'r--','linewidth',2.5); hold on; grid on;legend('cordicexp');
subplot(2,1,2);plot(1:length(y),real(y2),'b--','linewidth',2.5); hold on; grid on;legend('exponential');
  6 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!