MATLAB Answers


disp function error in matlab coder

Asked by aarthy reddy R on 14 Oct 2019
Latest activity Commented on by Adam
on 14 Oct 2019
disp(["Generation #", int(g)]);
the above line is showing error in my code
shows following error
Error in GeneticAlgorithm (line 11)
disp(["Generation #", int(g)]);
any suggestions for this error


Sign in to comment.

1 Answer

Answer by Adam
on 14 Oct 2019

disp is not supported by Coder. sprintf should work though.


can u kindly help me out for using disp function
because i am getting errors by using sprintf function
on 14 Oct 2019
I don't know what
is supposed to represent. There isn't an int() function in base Matlab. I also don't know what you are doing with sprintf to give you errors since you didn't post it.
In general sprintf can very simply directly replace disp, but I don't know what your disp function is trying to output since I don't know what int( ) is.
sprintf( "Generation #%i", g )
should theoretically work fine though.

Sign in to comment.