Programming and Graphics

(Kiana) #1

298 Introduction to C++ Programming and Graphics


(^00) 0.2 0.4 0.6 0.8 1
0.1
0.2
0.3
0.4
0.5
metrisis
hronos
Figure 9.4.1 A two-dimensional plot generated byMatlabthrough C++ code.
#include
#include
#include "engine.h"
using namespace std;
int main()
{
//--- Define the nodes:
const short Nx = 33; // size of the data vector
const short Ny = 17; // size of the data vector
double x[Nx+1], y[Ny+1];
double z[Nx+1][Ny+1];
//--- x grid lines:
for (int i=0; i<=Nx; i++)
{
x[i]= (i-1.0+1.0)/Nx;
}
//--- y grid lines:
for (int j=0; j<=Ny; j++)
{
y[j]= (j-1.0+1.0)/Ny;
}

Free download pdf