Plotting sine functions using linspace command
古いコメントを表示
Given: 
Find: Create a variable y that calculates the following function for the range of t.
The variable, t, should contain 450 data points, in the interval shown below. You should be using the linspace command for this because you are provided with the number of points in the array.
Don't forget your operators! You are calculating the value of y at each individual element of t.
Once you have your t and y vectors filled with values, plot y as a function of t. Remember that, when using the plot function, there should be 2 input arguments: the horizontal coordinates come first and the vertical come second. Try adding the following code to label your plot:
xlabel('t')
ylabel('y')
title('Plotting Sine Functions')
My Solution: I got as far as to state the following:
t = linspace(-4*pi,4*pi,450);
y = 4*t*sin*(2*t);
plot(t,y)
However I was getting an error in my y...
4 件のコメント
Dyuman Joshi
2024 年 2 月 25 日
What exactly is your question?
Sam Chak
2024 年 2 月 25 日
What do you mean?
Spaceman
2024 年 2 月 26 日
Spaceman
2024 年 2 月 26 日
採用された回答
その他の回答 (1 件)
It says to plot y as a function of t. You can follow this example to make the plot.
You can learn more about linspace() and plot() in the documentation.
y = @(t) sin(pi*t).*(cos(pi*t)); % create y as a function of t
t = linspace(-pi/2, pi/2, 900); % use linspace to create 900 points over the range -π/2 < t < π/2
plot(t, y(t)), grid on % make the plot
2 件のコメント
Spaceman
2024 年 2 月 26 日
Sam Chak
2024 年 2 月 26 日
@Kyle Weaver, It's a way of creating an anonymous function. Check out this article:
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


