Plotting a rotation time history with 4 slopes. The rotational device produces 1-12 deg/sec of any value. How to plot (Please see image)

1 回表示 (過去 30 日間)
Plotting a rotation time history with 4 slopes. The rotational device produces 1-12 deg/sec of any value. How to plot (Please see image)

回答 (1 件)

Avni Agrawal
Avni Agrawal 2025 年 2 月 26 日
編集済み: Avni Agrawal 2025 年 2 月 26 日
I understand that you are trying to plot rotational time history with different slopes. Please take a look at below code example in-order to achieve this.
% Define time intervals for each segment
t1 = 0:0.1:1; % Segment 1
t2 = 1:0.1:2; % Segment 2
t3 = 2:0.1:3; % Segment 3
t4 = 3:0.1:4; % Segment 4
% Define rotational speeds for each segment (random values between 1 and 12)
speed1 = 3; % deg/sec
speed2 = 8; % deg/sec
speed3 = 5; % deg/sec
speed4 = 10; % deg/sec
% Calculate the angle for each segment
theta1 = speed1 * (t1 - t1(1));
theta2 = theta1(end) + speed2 * (t2 - t2(1));
theta3 = theta2(end) + speed3 * (t3 - t3(1));
theta4 = theta3(end) + speed4 * (t4 - t4(1));
% Combine time and angle data
t = [t1, t2(2:end), t3(2:end), t4(2:end)];
theta = [theta1, theta2(2:end), theta3(2:end), theta4(2:end)];
% Plot the results
figure;
plot(t, theta, '-o');
xlabel('Time (sec)');
ylabel('\theta (degrees)');
title('Rotation Time History');
grid on;
I hope this helps!

カテゴリ

Help Center および File ExchangeInteractions, Camera Views, and Lighting についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by