5.1 Generate a plot using x and y data

Problem: Generate \(x\) and \(y\) data for \(sin(x)\) and plot the data.

Mathematica

Remove["Global`*"]; 
data = Table[{x,Sin[x]}, 
        {x, -2Pi,2 Pi,Pi/100}]; 
ListPlot[data, 
     Frame -> True, 
     GridLines->Automatic, 
     GridLinesStyle->Dashed, 
     ImageSize->300, 
     AspectRatio->1, 
     PlotStyle->Red, 
     FrameLabel->{{"sin(x)",None}, 
        {"x","plot of sin(x)"}}, 
     FrameTicks->{{-2Pi,-Pi,0,Pi,2Pi}, 
                None,Automatic,None} 
     ]
 

pict

 

Matlab

clear all; 
x = -2*pi:pi/100:2*pi; 
plot(x,sin(x),'r'); 
grid on; 
title('plot of sin(x)'); 
xlabel('x'); 
ylabel('sin(x)'); 
set(gca,'XTick',-2*pi:pi:2*pi) 
set(gca,'XTickLabel',... 
   {'-2*pi','-pi','0','pi','2*pi'}) 
set(gcf,'Position',[10,10,340,340]);
 

pict

 

Maple

restart; with(plots); 
lis := [seq(sin((1/100)*theta), theta = 1 .. 1000)]; 
listplot(lis, axes = box)
 

pict