How to fill a vector with values and plot?

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 comentario

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)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Etiquetas

Preguntada:

el 31 de Mzo. de 2017

Comentada:

Rik
el 31 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by