Is there a workaround to conditionally import java class to import list in MATLAB?
Mostra commenti meno recenti
I guess the answer is no, but I'd like to try.
Is there a workaround to conditionally import java class to import list in MATLAB? The documentation of MATLAB simply denies it.
> Do not use import in conditional statements inside a function. MATLAB preprocesses the import statement before evaluating the variables in the conditional statements.
function func1()
...
if A
import ij.process.LUT
end
...
end
I wanted to implement something like this in a function, because it is not guaranteed that ij.process.LUT is within MATLAB's scope. Simply calling import ij.process.LUT will cause an error in some scenarios.
The following trick did not work, since it appears that MATLAB evaluates import statements before actually running code.
function func2()
...
try
if A
import ij.process.LUT
end
catch
end
...
end
Risposta accettata
Più risposte (1)
Kouichi C. Nakamura
il 17 Mag 2018
Categorie
Scopri di più su Call Java from MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!