I am attempting to write a light script to deal with multiple package installation in Octave. The available packages can be checked in Octave Forge or wikipedia. For example, if the packages data-smoothing, fuzzy-logic toolkit, image, image-acquisition, parallel, statistics and video are needed to be installed, list these package names into Packages collection, such as:

Packages{1} = "data-smoothing";
Packages{2} = "fuzzy-logic toolkit";
Packages{3} = "image";
Packages{4} = "image-acquisition";
Packages{5} = "parallel";
Packages{6} = "statistics";
Packages{7} = "video";

Then pass it into InstallPackages function.


The experimental implementation

function [] = InstallPackages(Packages)
  for i = 1:size(Packages, 2)
      fprintf("Package %s is about to be installed!\n", Packages{1, i});
      pkg('install', '-forge', Packages{1, i});
    catch (exception)
      fprintf("Package %s installation failed!\n", Packages{1, i});

All suggestions are welcome.

  • 1
    \$\begingroup\$ You don’t need eval, you can just do pkg('install', '-forge', Packages{1, i}) \$\endgroup\$ Oct 2 at 0:43
  • \$\begingroup\$ @Cris Luengo Thank you for the suggestion. Already updated. \$\endgroup\$
    – JimmyHu
    Oct 4 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.