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

11 vues (au cours des 30 derniers jours)
vanita
vanita le 16 Jan 2013
#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();
}

Réponses (1)

Ryan G
Ryan G le 16 Jan 2013

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by