how to plot x(t) vs t when equation is x = 60+30sin(wt) (w=1 and t is a uniform random variable)

1 回表示 (過去 30 日間)
Lynsey King
Lynsey King 2022 年 3 月 6 日
回答済み: Image Analyst 2022 年 3 月 6 日
how to plot x(t) vs t when equation is x = 60+30sin(wt) (w=1 and t is a uniform random variable).
Every time i try to plot the equation nothing shows up on my figure. Here is my code so far
w=1;
t=30.01:0.01:89.99;
X=60+30*w*sin(w*t*2*pi);
figure(1);
title('Graph of X(t) vs t')
plot(t,X);
xlabel('t');
ylabel('X(t)');
xlim([20 100]);
ylim([0 1]);

回答 (2 件)

David Hill
David Hill 2022 年 3 月 6 日
編集済み: David Hill 2022 年 3 月 6 日
w=1;
t=30.01:0.01:89.99;
X=60+30*w*sind(w*t*2*pi);%you likely want sind (degrees not radians)
figure(1);
title('Graph of X(t) vs t')
plot(t,X);
xlabel('t');
ylabel('X(t)');
%xlim([20 100]);
%ylim([0 1]); ylim too small, let auto range

Image Analyst
Image Analyst 2022 年 3 月 6 日
You ylim was wrong. Your data goes outside the range of 0 to 1. Try this:
w=1;
numElements = 50; % whatever you want.
t = sort(30.01 + (89.99 - 30.01) * rand(1, numElements));
X=60+30*w*sin(w*t*2*pi);
title('Graph of X(t) vs t')
plot(t, X, 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
grid on;
xlabel('t');
ylabel('X(t)');
xlim([20 100]);

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by