Testing Bash variable to decide whether to use MATLAB or Runtime
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using a Bash script to test a Java package created from an m-file function using Compiler SDK. I want the script to use either Matlab, if it is installed, or the Matlab Runtime if the former is not installed.
Based on the Stack Overflow answer https://stackoverflow.com/a/17157187, I tried testing the flow control at the Bash command line:
$ UseMLorRT=MATLAB # Next, test if this choice is properly recognized
$ if [ "$UseMLorRT"="MATLAB" ]; then echo UseMatlab; else echo UseRuntime; fi
UseMatlab
$ if [ "$UseMLorRT"="Runtime" ]; then echo UseMatlab; else echo UseRuntime; fi
UseMatlab
The setting `UseMLorRT=MATLAB` is not being recognized. In the second `if-else` statement above, `echo UseRuntime` should be executed, but it is not. I get the same behaviour by comparing using "==" instead of "=" and if I use double square brackets instead of single square brackets.
Can anyone see what I am doing wrong?
2 commentaires
Walter Roberson
le 27 Avr 2023
https://linuxize.com/post/bash-case-statement/ you could use a case statement
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Identification 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!