Vector x produce another vector s

1 view (last 30 days)
Orlando
Orlando on 8 Nov 2011
Dear all, this is my problem:
I have written this code:
x=-4:0.2:4
y2=x.^2
plot(x, y2)
xLabel('x-variable')
yLabel('multi-functions')
title('Orlando Bellincampi, Figure 1.1, 27/10/11')
%New Section
y3=x.^3
hold on
plot(x, y3, '--r')
p2=pow2(x)
plot(x, p2, '-.k')
Now I should do: #Add a line of code that uses the values in vector x to produce another vector s so that when plotted will give 2 cycles of a sinusoid over the range of x.
You will need to use the function sin(), whose argument is 2pix/T with T being the period of the sine wave. Determine T so that the argument ranges from -2pi to +2pi (hence two cycles). Also you will need to scale s by multiplying it with an appropriately large value, otherwise the sine wave will not be visible among the other curves.
Add a command in the program to plot the scaled data s against x, on the same graph.
Actually I am a really beginner.
What should I do? Thanks a lot for your attention and time.
Orlando

Answers (1)

Wayne King
Wayne King on 8 Nov 2011
Well, without just doing everything for you. Your x vector runs over an interval of 8. So, if the sine wave has 2 periods in 8 x-units...
also it's not xLabel() and yLabel().
A sine wave oscillates between [-A,A] so you have to set your amplitude (multiply your sine wave) by the appropriate A.
There are many examples in the MATLAB doc that create simple sine waves.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!