Can I run a matlab file with symbolic functions from the command line?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Antonio Scala
le 10 Déc 2019
Réponse apportée : Ridwan Alam
le 10 Déc 2019
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 commentaires
Réponse acceptée
Ridwan Alam
le 10 Déc 2019
syms x_1;
syms x_2;
syms x_3;
syms x_4;
syms x_5;
syms x_6;
Hope this helps!
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Assumptions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!