Can I run a matlab file with symbolic functions from the command line?
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to run this file below with symbolic expresssions. It runs in the editor and it does output to the two files below with no errors.
A = [1 1 1 1 1 2 2; 1 3 2 6 4 2 6; 1 2 4 1 2 5 3; 1 6 1 6 1 5 2; 1 4 2 1 4 5 6; 1 5 4 6 2 4 6];
sym x_1;
sym x_2;
sym x_3;
sym x_4;
sym x_5;
sym x_6;
Q = [x_1 x_2 x_3 x_4 x_5 x_6 1];
solution = solve(A*Q.');
answer = [solution.x_1 solution.x_2 solution.x_3 solution.x_4 solution.x_5 solution.x_6 1];
answer = mod(answer, 7);
answer = answer*10;
answer = mod(answer, 7);
answer = double(answer);
check = mod(A*answer.',7);
check = double(check);
writematrix(answer, "test2.txt");
writematrix(check, "check.txt");
But when I try to run it from the command line using:
matlab -nodisplay -nosplash -nodesktop -r "run('C:\pathtofile\file.m');"
It returns an error saying that the variable x_1 does not exist. Does that mean symbolc expressions cannot work from the command line?
0 件のコメント
採用された回答
Ridwan Alam
2019 年 12 月 10 日
syms x_1;
syms x_2;
syms x_3;
syms x_4;
syms x_5;
syms x_6;
Hope this helps!
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!