home Forums # Technical Support Equivalent of fismain.c from MATLAB distribution Reply To: Equivalent of fismain.c from MATLAB distribution

#871

Keymaster

Dear Witold,

Another person recently requested the same feature in the forums. I will definitely incorporate such a simple function in the next version. I had no idea about it because I have rarely used Matlab for fuzzy logic control, or anything else for that matter.

Anyway, what you require is not too hard and you do not need to build fuzzylite from source to achieve so.

Roughly, in SomeFile.cpp:



int main(int argc, char** argv){
fl::Engine* engine = FisImporter().fromString(fisEngine);
for (std::size_t i = 0 ; i < inputs.size(); ++i){
for (std::size_t x = 0 ; x < inputs.at(i).size(); ++x){
engine->getInputVariable(x)->setInputValue(inputs.at(i).at(x));
}
engine->process();
for (int i = 0 ; i < engine->numberOfOutputVariables(); ++i){
fl::scalar output = engine->getOutputVariable(i)->defuzzify();
writeToSomeFile(output + " ");
}
writeToSomeFile(output + "\n");
}


You have to implement yourself the read and write functions and fix some details.

g++ SomeFile.cpp -I/path/to/fuzzylite/fuzzylite -L/path/to/fuzzylite/fuzzylite/bin -lfuzzylite