Vector x produce another vector s

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

답변 (1개)

Wayne King
Wayne King 2011년 11월 8일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2011년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by