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 views (last 30 days)
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)

Answers (1)

Avni Agrawal
Avni Agrawal on 26 Feb 2025
Edited: Avni Agrawal on 26 Feb 2025
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!

Categories

Find more on Interactions, Camera Views, and Lighting in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!