Filter löschen
Filter löschen

i am new to s function,,,how to create s function from existing matlab or c code

1 Ansicht (letzte 30 Tage)
#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();
}

Antworten (1)

Ryan G
Ryan G am 16 Jan. 2013

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by