How to fill a vector with values and plot?

8 次查看(过去 30 天)
Hello everyone
I am realtive new in MatLab and got a question for plotting a vector.
So I have the function 1/x sin²(x)
I need to create a vector with values from 1 to 10 in 0.25 steps
So I created the vector like this
y=[1:0.2:10]
Now I need to fill the vector with values from x so basically I use the values from y e.g. 0.25 and put in in the function.
How can I do this in MatLab?
And the last step is to plot the function for plotting I need to create a time vector e.g.
t[-5:0.25:5]
plot (y,t)
Does this look right?
Thanks for your help !
  1 个评论
Rik
Rik 2017-3-31
It sounds like you would really benefit from one of the many tutorials on how to get started with Matlab. I'll give you the answer, but this is one of the first things you will learn with such a tutorial.
t=-5:0.25:5;
y=1/(t.*sin(t).^2);%use .* and .^ for element-wise product and power
plot(t,y)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by