How to fill a vector with values and plot?
조회 수: 9 (최근 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
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 Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!