Двоичный оператор октавной ошибки '==' не реализован для 'cs-list' операциями 'matrix' - PullRequest
0 голосов
/ 05 ноября 2019

Я получаю эту ошибку при программировании в октаве. Я довольно новичок в октаве и никогда не сталкивался с этой ошибкой. Мой основной код скрипта:

pkg load symbolic      # Load the octave symbolic library
syms x1 x2             # Define symbolic variables x1 and x1

x1_dot = -x1 + 2*x1^3 + x2;       # Write the expressions for x1_dot and x2_dot
x2_dot = -x1 - x2;   # YOU CAN MODIFY THESE 2 LINES TO TEST OUT OTHER EQUATIONS

[equilibrium_points jacobians eigen_values stability] = main_function(x1_dot, x2_dot);

Код в файле main_function.m:

function eqbm_points = find_equilibrium_points(x1_dot, x2_dot)
  x1_dot == 0;
  x2_dot == 0;

  syms x1 x2
  solve(x2_dot,x1_dot,x1,x2);
  eqbm_points=[x1 x2];
  ############################################################  
endfunction


function jacobian_matrices = find_jacobian_matrices(eqbm_points, x1_dot, x2_dot)
  syms x1 x2;
  solutions = {};
  jacobian_matrices = {};
  for k = 1:length(eqbm_points)
    x_1 = eqbm_points{k}.x1;
    x_2 = eqbm_points{k}.x2;
    soln = [x_1 x_2];
    solutions{k} = soln;
  endfor
  ##########################################################
  secs=[x1 x2];
  max=[x1_dot x2_dot];
  jm={};
  for k = 1:length(max)
    for l = 1:length(secs)
   jm{k}{l}=jacobian(max{k},secs{l});
   endfor
  endfor 
  for k = 1:length(eqbm_points)
    jacobian_matrices{k}=subs(jm,{x1,x2},solutions{k});
  endfor



  ############################################################  
endfunction


function [eigen_values stability] = check_eigen_values(eqbm_pts, jacobian_matrices)
  stability = {};
  eigen_values = {};
  for k = 1:length(jacobian_matrices)
    matrix = jacobian_matrices{k};
    flag = 1;
    ##################
    syms s
     mat= eye (2);
     eign=s.*mat.-matrix;
     solve(eign,s);
     eigen_values{k}=s;
     if s<0
       flag=1;
      else 
       flag=0;
     endif
    ############################################################
    if flag == 1
      fprintf("The system is stable for equilibrium point (%d, %d) \n",double(eqbm_pts{k}.x1),double(eqbm_pts{k}.x2));
      stability{k} = "Stable";
    else
      fprintf("The system is unstable for equilibrium point (%d, %d) \n",double(eqbm_pts{k}.x1),double(eqbm_pts{k}.x2)); 
      stability{k} = "Unstable";
    endif
  endfor
endfunction


function [equilibrium_points jacobians eigen_values stability] = main_function(x1_dot, x2_dot)
  pkg load symbolic      # Load the octave symbolic library
  syms x1 x2             # Define symbolic variables x1 and x1
  equilibrium_points = find_equilibrium_points(x1_dot, x2_dot);
  jacobians = find_jacobian_matrices(equilibrium_points, x1_dot, x2_dot);
  [eigen_values stability] = check_eigen_values(equilibrium_points, jacobians); 
endfunction

Ошибка:

error: binary operator '==' not implemented for 'cs-list' by 'matrix'
operations error: parse error error: called from
    subsref at line 55 column 3
    find_jacobian_matrices at line 47 column 9
    main_function at line 127 colum n 13
    C:/Users/shind/Downloads/Main_F ile (1).m at line 7 column 58

Что не так? Как мне это исправить?

...