Help me plot 256 values from 0 to x that follows exponential curve

Status
Not open for further replies.

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,896
Helped
438
Reputation
880
Reaction score
288
Trophy points
1,363
Location
Oberon
Activity points
12,887
I would like to plot 256 values from 0 to x that follow an exponential curve.
Could somebody please help.
 

Re: Exponential curve

Dear btbass,

You can do simply this by using of Excel in Microsoft office or Calc in OpenOffice.
1) Create a column with your 256 values of X. First value =0, second value (next box below) = value of your step. After that select the two box and pull it with the mouse (maintaining the left button) until the 256th box. You have your X values.
2) Select the column at rigth (it will be your Y values). Click on the box just beside the first value of the X column. Define your function inside (something like "=EXP(A1)" for an exponential function). A1 being the name of the first box of the X column. Afterthat, select the whole Y column and click on the function "fill" in the "edit" menu. Now, you have obtained your Y values. You can plot Y vs. X with Excel or Calc software. Or you can export the table with X and Y columns in ASCII mode for example if you want to use it in another program.

Good luck,

Elvis

btbass said:
I would like to plot 256 values from 0 to x that follow an exponential curve.
Could somebody please help.
 

    btbass

    Points: 2
    Helpful Answer Positive Rating
Re: Exponential curve

if i understand correctly, u want to plot an y=e^x function with 256 samples ,
this can be done with simple matlab code
Code:
x=[0:0.1:(256-1)];   %i used a step of 0.1 , u can change it
y=exp(x);
plot(x,y);
grid on;

note this will give u , a continous curve if u want to plot just ur values "discrete points", follow the same program then instead of plot use the command "cftool"
this will open the curve fitting tool,add the points and plot.
 

    btbass

    Points: 2
    Helpful Answer Positive Rating
Re: Exponential curve

besides using matlab, u also can programing by C. it is very simple.
 

Exponential curve

Thanks guys, it is for translating a byte value 0-255 to a pwm duty cycle that goes from 0 - 416 with an exponential response.
 

Re: Exponential curve

sorry , i forget to add the parameter x
Code:
x=9 ;                       
z=[0:0.1:x*(256-1)];   %i used a step of 0.1 , u can change it
y=exp(z);
plot(z,y);
grid on;
% 9 is the value of x , u can get it from other function, or just put the value u want.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…