I just move from Matlab to C ;;;;;
I am trying to plot a Simple sin curve in C
I have few questions !
1. How i can get out put in terms of dat file ! I want to plot it in matlab later
2. In Matlab, when i run the same algorithmi get negative amplitudes also but here i am getting all positive ! This means my code is wrong some where
3. Also if i want to take random values of t1 instead of uniform ! suppose i want to chuck of 10% from this what should i do
Thanks
I am trying to plot a Simple sin curve in C
Code:
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795l
int main()
{
const float dt = .001;
int i, n ;
float t,t1, y;
t=0.0;
n=20;
printf(" i t y \n");
printf("------------------------------------ \n");
for (i = 0; i <= n; i++)
{
t1=i*dt;
y = sin(2*PI*t1);
printf("%d %5e %2e \n", i, t1, y);
}
return 0;
}
I have few questions !
1. How i can get out put in terms of dat file ! I want to plot it in matlab later
2. In Matlab, when i run the same algorithmi get negative amplitudes also but here i am getting all positive ! This means my code is wrong some where
3. Also if i want to take random values of t1 instead of uniform ! suppose i want to chuck of 10% from this what should i do
Thanks
Comment