Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
#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();
}

Respuestas (1)

Ryan G
Ryan G el 16 de En. de 2013

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by