Images.jl not working with JuMP output in for loop

I am trying to represent a matrix as black and white squares.
Example: This works for me for one time.
using Colors, Images
y = [0.5 0.5; 0.7 0.3]
imgg = Gray.(y)

This does not work in following case:

function abc(x)
using JuMP
create optimization model with variable x
solve
return x_value (returns matrix)

for j in 1:5
y = abc(j)
imgg = Gray.(y)
end

this should create 5 graphs but this is not creating any graph.

It’s hard to guess what’s going wrong unless you copy/paste an example that anyone can run. There isn’t enough information to make a good guess about what aspect of this isn’t working.

1 Like