| 1 |
n = 20; % number of points |
| 2 |
points = [random('unid', 100, n, 1), random('unid', 100, n, 1)]; |
| 3 |
len = zeros(1, n - 1); |
| 4 |
points = sortrows(points); |
| 5 |
%% Initial set of points |
| 6 |
plot(points(:,1),points(:,2)); |
| 7 |
for i = 1: n-1 |
| 8 |
len(i) = points(i + 1, 1) - points(i, 1); |
| 9 |
end |
| 10 |
while(max(len) > 2 * min(len)) |
| 11 |
[d, i] = max(len); |
| 12 |
k = on_margin(points, i, d, -1); |
| 13 |
m = on_margin(points, i + 1, d, 1); |
| 14 |
xm = 0; ym = 0; |
| 15 |
%% New point |
| 16 |
if(i == 1 || i + 1 == n) |
| 17 |
xm = mean(points([i,i+1],1)) |
| 18 |
ym = mean(points([i,i+1],2)) |
| 19 |
else |
| 20 |
[xm, ym] = dlg1(points([k, i, i + 1, m], 1), ... |
| 21 |
points([k, i, i + 1, m], 2)) |
| 22 |
end |
| 23 |
|
| 24 |
points = [ points(1:i, :); [xm, ym]; points(i + 1:end, :)]; |
| 25 |
end |
| 26 |
|
| 27 |
%{ |
| 28 |
This is a block comment. Please ignore me. |
| 29 |
%} |
| 30 |
|
| 31 |
function [net] = get_fit_network(inputs, targets) |
| 32 |
% Create Network |
| 33 |
numHiddenNeurons = 20; % Adjust as desired |
| 34 |
net = newfit(inputs,targets,numHiddenNeurons); |
| 35 |
net.trainParam.goal = 0.01; |
| 36 |
net.trainParam.epochs = 1000; |
| 37 |
% Train and Apply Network |
| 38 |
[net,tr] = train(net,inputs,targets); |
| 39 |
end |
| 40 |
|
| 41 |
foo_matrix = [1, 2, 3; 4, 5, 6]'''; |
| 42 |
foo_cell = {1, 2, 3; 4, 5, 6}''.'.'; |
| 43 |
|
| 44 |
cell2flatten = {1,2,3,4,5}; |
| 45 |
flattenedcell = cat(1, cell2flatten{:}); |