myex22.m 646 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. clear ; close all; clc
  2. %% Load Data
  3. % The first two columns contains the X values and the third column
  4. % contains the label (y).
  5. data = load('ex2data2.txt');
  6. X = data(:, [1, 2]); y = data(:, 3);
  7. X = mapFeature(X(:,1), X(:,2));
  8. % Initialize fitting parameters
  9. % Compute and display initial cost and gradient for regularized logistic
  10. % regression
  11. %test_theta = ones(size(X,2),1);
  12. %[cost, grad] = costFunctionReg(test_theta, X, y, 10);
  13. a = randi(10,5,5)
  14. b = randi(9,5,1)
  15. a*b
  16. [zeros(rows(a), 1) a(:, 2:end)];
  17. c = [a(:,1) [zeros(rows(a), columns(a) -1)]]
  18. c * b
  19. d = [zeros(rows(a), 1) [a(:,2:end)]]
  20. d * b
  21. e = (c*b) + (d*b) - (a*b)