default.txt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. points = [ points(1:i, :); [xm, ym]; points(i + 1:end, :)];
  24. end
  25. %{
  26. This is a block comment. Please ignore me.
  27. %}
  28. function [net] = get_fit_network(inputs, targets)
  29. % Create Network
  30. numHiddenNeurons = 20; % Adjust as desired
  31. net = newfit(inputs,targets,numHiddenNeurons);
  32. net.trainParam.goal = 0.01;
  33. net.trainParam.epochs = 1000;
  34. % Train and Apply Network
  35. [net,tr] = train(net,inputs,targets);
  36. end
  37. foo_matrix = [1, 2, 3; 4, 5, 6]''';
  38. foo_cell = {1, 2, 3; 4, 5, 6}''.'.';
  39. cell2flatten = {1,2,3,4,5};
  40. flattenedcell = cat(1, cell2flatten{:});