Is there a workaround to conditionally import java class to import list in MATLAB?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Kouichi C. Nakamura
le 17 Mai 2018
Catégories
En savoir plus sur Call Java from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!