Testing Bash variable to decide whether to use MATLAB or Runtime
4 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 27 Apr 2023
https://linuxize.com/post/bash-case-statement/ you could use a case statement
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!