Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions create_motors.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
% Creates a list of motor objects
function [motors] = create_motors()

% 1st column: max torque
% 2nd col: max speed
% 3rd col: weight
motor_specs_list = [
1.76, 251, 205;
0.637, 380, 160;
0.69, 216, 136;
0.6, 500, 98;
1.18, 350, 98;
0.98, 210, 96;
0.69, 150, 160
];

motors = [];
s = size(motor_specs_list);
number_of_motors = s(1);
for i=1:number_of_motors
new_motor = motor(motor_specs_list(i,1), motor_specs_list(i,2), motor_specs_list(i,3));
motors = [motors, new_motor];
end
end
16 changes: 16 additions & 0 deletions motor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
classdef motor
properties
torque;
speed;
weight;
end

methods
function obj = motor(torque, speed, weight)
obj.torque = torque;
obj.speed = speed;
obj.weight = weight;
end
end
end

47 changes: 47 additions & 0 deletions motor_specs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
clear;
close all;

% 1st column: max torque
% 2nd col: max speed
% 3rd col: weight
motor_specs_list= [
1.76, 251, 205;
0.637, 380, 160;
0.69, 216, 136;
0.6, 500, 98;
1.18, 350, 98;
0.98, 210, 96;
0.69, 150, 160
];

torque = motor_specs_list(:,1);
speed = motor_specs_list(:,2);
weight = motor_specs_list(:,3);

% Plot max torque vs max speed
plot(torque, speed, '.r', 'MarkerSize', 20);
title('Max Torque vs Max Speed');
xlabel('Max Torque (Nm)');
ylabel('Max Speed (rpm)');
axis([0, 2, 0, 600]);

% Plot max torque vs weight
figure;
plot(torque, weight, '.r', 'MarkerSize', 20);
title('Max Torque vs Weight');
xlabel('Max Torque (Nm)');
ylabel('Weight (g)');
axis([0, 2, 0, 300]);

% Plot motot curves (torque vs speed)
figure
s = size(torque);
for i=1:s(1)
txt = ['motor ',num2str(i)];
plot([0,torque(i)],[speed(i),0],'--', 'DisplayName', txt);
hold on;
end
title('Motor curves');
xlabel('Torque (Nm)');
ylabel('Speed (rpm)');
legend show;