i am new to s function,,,how to create s function from existing matlab or c code
2 views (last 30 days)
Show older comments
#include<math.h>
#include<conio.h>
#include<stdio.h>
main()
{
int root,n,i,m,seq2[100];
float x,y,seq,seq1[100],sum=0,avg,pi=3.142;
clrscr();
root=36;
m=16;
i=1;
for(n=1;n<=m;n++)
{
x=((root*n*(n+1)*pi)/m);
/* printf("exp=%f",exp(-x)); */
y=-x;
printf("x=%f\t y=%f \t \n ",x,y);
seq=exp(y); /*this line is not working */
printf(" \n seq=%f",seq);
/* seq=exp(-(root*n*(n+1)*PI)/m); not getting correct output here exp() is not working
printf(" \n seq=%f",seq); */
sum=sum+seq;
seq1[i]=seq;
i=i+1;
}
avg=sum/m;
for(i=1;i<=m;i++)
{
if(seq1[i]>=avg)
{
seq2[i]=1;
}
else
{seq2[i]=0;
}
printf("\n binary=%d",seq2[i]);
}
getch();
}
0 Comments
Answers (1)
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!