Skip to content

Commit

Permalink
update dynamic programming
Browse files Browse the repository at this point in the history
  • Loading branch information
edxu96 committed May 13, 2020
1 parent a39dba2 commit 83a79bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/dynamic/cal_chain.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
end


function [u_i, v_i] = optim_2d_solve(z_i, y_i, lambda_z_i1, lambda_y_i1, m, g, l)
function [u_i, v_i] = optim_2d_solve(z_i, y_i, lambda_z_i1, lambda_y_i1, ...
m, g, l)
% Trigonometric functions cannot be used in `solve`

x = optimvar('x', 2, 1, 'LowerBound', [-l; -l], 'UpperBound', [l; l]);
Expand All @@ -86,7 +87,7 @@


function [u_i, v_i] = optim_2d_fmincon(z_i, y_i, lambda_z_i1, lambda_y_i1, ...
m, g, l)
m, g, l)
% Two Dimension Method using Pontryagins Maximum Principle
% Trigonometric functions can be used in `fmincon`

Expand Down
4 changes: 2 additions & 2 deletions src/dynamic/get_data_chain_diff.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@


function struct_data = get_data_chain_diff(n)
function s_data = get_data_chain_diff(n)
s_total = 10;
m_total = 14;

struct_data = struct(...
s_data = struct(...
'rho', m_total / s_total, ...
'g', 9.81, ...
's_total', s_total, ...
Expand Down
7 changes: 4 additions & 3 deletions src/dynamic/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ function main()

%% Continuous Wire
solve_project_conti(z_t_1, y_t_1)

%% Trajectory of a Suspended Chain using Two Symmetric Half Chains
[z_t_1, y_t_1] = solve_project_discrete(true);
end


function [z_t_1, y_t_1] = solve_project_discrete(whe_sym)
% whe_sym: whether to use symmetric method

s_data_1 = get_data_chain(6); % When the number of sections is 6
s_data_2 = get_data_chain(100); % When the number of sections is 100
Expand Down Expand Up @@ -58,7 +59,7 @@ function plot_chain_discrete(x1, y1, x2, y2, name_fig)
ylabel('y')
legend('when N = 6','when N = 100')
hold off

% saveas(h, name_fig, 'png');
end

Expand All @@ -85,7 +86,7 @@ function plot_chain_conti(vec_x, vec_y, x1, y1)
ylabel('y')
legend('Suspended Wire','Suspended Chain with N = 6')
hold off

% saveas(h1, 'conti', 'png');
end

Expand Down
2 changes: 0 additions & 2 deletions src/dynamic/plot_chain.m

This file was deleted.

0 comments on commit 83a79bd

Please sign in to comment.