Programming and Graphics

(Kiana) #1

362 Introduction to C++ Programming and Graphics



  • Graph of the function:f(x)=sin^3 (πx)


>> x=-1.0:0.01:1.0; % define an array of abscissae
>> y = sin(pi*x).^3; % note the .^ operator (Table F.1.1)
>> plot(x,y)
>> set(gca,’fontsize’,15)
>> xlabel(’x’,’fontsize’,15)
>> ylabel(’y’,’fontsize’,15)

−1−1 −0.5 0 0.5 1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

x

y


  • Graph of the Gaussian function:f(x)=e−x
    2


>> fplot(’exp(-x^2)’,[-5, 5])
>> set(gca,’fontsize’,15)
>> xlabel(’x’,’fontsize’,15)
>> ylabel(’y’,’fontsize’,15)

−5^005

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

x

y
Free download pdf