Search code examples
octave

Why are the values ​of the expression not displayed in numeric format?


I have an expression (signal) and I want to get certain results using a loop. Original formula enter image description here

Code:

Ak=1.2;
fk=0.0123;
jK=0.321;
alphaK=-0.01;
T=1;

#Signal
#xi=1.2*cos(0,0123*2*pi*(i-1)+0.321)*eps(–0.01*i);

for i=1:4
  x(i)=Ak*cos(fk*2*pi*(i-1)+jK)*eps(alphaK*i);
end

The results are in this format

x = 1.9753e-18
x = 1.9753e-18   3.8375e-18
x = 1.9753e-18   3.8375e-18   3.7013e-18
x = 1.9753e-18   3.8375e-18   3.7013e-18   7.0863e-18

But the correct results look like this:

enter image description here

How do I change the format to get the correct display?


Solution

  • replace

    x(i)=Ak*cos(fk*2*pi*(i-1)+jK)*eps(alphaK*i);
    

    with

    x(i)=Ak*cos(fk*2*pi*(i-1)+jK)*exp(alphaK*i);
    

    and you will have a result much near to the expected one

    x =
    
       1.12737   1.08417   1.03531   0.98119
    

    eps is NOT the exponential function

    octave:3> eps
    ans =    2.2204e-16
    octave:4> eps(x)
    ans =
    
       2.2204e-16   2.2204e-16   2.2204e-16   1.1102e-16
    octave:5> exp(x)
    ans =
    
       3.0875   2.9570   2.8160   2.6676