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