Using MATLAB and C + + program generated data files to draw the Sin function

Source: Internet
Author: User
Tags sin

Software: matlabr2014a Codeblock

1. Create a new project


2. Enter the program, obtain the coordinates and save to TXT file


3. Using MATLAB to build a M file


4. Enter the drawing code,


5. Click Run, the M file is saved in the folder where the new project is located


6. Drawing complete


7. If you want to save the image in a different format, click on Save As, select Save Type, here to select the PDF format, this is the saved image.


Summary: Originally very simple things, the class after listening to no hands-on practice, a classmate asked to find that they did not remember,-_-#

Take a good look at yourself.

CPP Source code:

  Practical Application---Function image # include <iostream> #include <fstream>//input/output stream # include <cmath>using namespace Std;int Main () {Ofstream out_y ("Y.txt");  Ofstream---Output stream, out--object Ofstream out_x ("X.txt"); int i,m=100;float dx=0.2;for (i=0;i<=m;i++) {OUT_X<<I*DX << ' \ t '; Out_y<<sin (i*dx) << ' \ t ';} Out_x.close (); Out_y.close (); return 0;}

Matlab code:

Load X.txtload y.txtplot (x, y)


Using MATLAB and C + + program generated data files to draw the Sin function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.