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)

2 次查看(过去 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 CenterFile Exchange 中查找有关 Interactions, 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