473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Simple SIn Curve

I just move from Matlab to C ;;;;;

I am trying to plot a Simple sin curve in C
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. #include <math.h>
  4. #include <stdio.h>
  5.  
  6. #define PI 3.1415926535897932384626433832795l
  7.  
  8. int main()
  9. {
  10.   const float dt = .001;
  11.   int i, n ;
  12.   float  t,t1, y;
  13.   t=0.0;
  14.   n=20;
  15.   printf(" i             t                   y \n");
  16.   printf("------------------------------------ \n");
  17.   for (i = 0; i <= n; i++)
  18.   {
  19.      t1=i*dt;
  20.      y = sin(2*PI*t1);
  21.      printf("%d %5e %2e \n", i, t1, y);
  22.   }
  23.   return 0;
  24. }
  25.  

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
May 30 '10 #1
2 2077
Oh its fine i corrected this code but still i am not able to figure it out how can i chop of 30% of values from this curve randomly...............i wabt to use rand not srand as i am looking for chopping 5% fst then 10%..slowly slowly 50%
May 30 '10 #2
weaknessforcats
9,208 Expert Mod 8TB
I don't know if this is important to you but a float contains only 6 significant digits. A double has only 15.
May 30 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Vinodh Kumar | last post by:
Number One: ========= I know its a 100% offline post.But seeing the diversity of the domain from which people are participating, I would like to post this question here.Pardon me.At the least, u...
5
by: reagan | last post by:
I am trying to get a program(in visual C++) to draw a sine curve (from 0 to 2pi). It takes 8 lines to draw the complete curve. However, the user can choose to use up to 100 lines to make the curve...
2
by: MLH | last post by:
This question, I apologize, is more of a math question than it is an Access question - I'm almost certain. The bell curve is another name for the normal distribution, which is a common type of...
4
by: nmukh1 | last post by:
Hey guys, I'm trying to optimize a program that measures the length of a curve. Suppose I define a function f and I have two bounds and am trying to find the arc length. The familiar calculus...
0
by: david | last post by:
I want draw the statistical curve diagrams (such as density, probability) on web page or window form. I know how to use OWC10 for simple chart, but I do not know how to set the parameters for...
4
by: babyinc | last post by:
Please help me. I am totally beginner of C++ and my tutor give us these huge program to solve within 20 days. As a MSc student I am really gonna cry. Please anyone can help me. sumon1in1@yahoo.com ...
26
by: K.J.Williams | last post by:
Hello, A friend and I want to learn PHP but we have two totally different programming backgrounds. I have experience with procedural programming in C, and he has experience with Visual BASIC....
0
by: sa6113 | last post by:
Hello there, I have a problem on curve fitting , would you please help me ?! I want to to develop a application that reads a text file with 2 columns of floating point data (as x and y) and...
0
by: RAZA1 | last post by:
hello, i am using Visual studio environment to run GUI in c#, which is connecting to a Micro controller via Rs232, the problem is i am getting a wave on GUI (sometimes multiple waves)(using A/D...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.