I am currently working on getting matlab to run an ansys model, retrieve principal stresses, and feedback into a matlab optimizer, specifically fmincon. My issue is not one of communication of variables (everything seems to be passing well between the 2 programs), however, fmincon evaluates the objective function with the same design variables for every iteration. In other words, it takes my initial guess and uses it for every iteration as if it is not changing the input variables based upon the feedback it is receiving. I have the same problem regardless of the initial guess I make. If I make a guess outside of the upper and lower bounds I have set, fmincon will use the closest feasible points within the bounds. I have no constraints other than bounds on the design variables. My objective function calls an ansysfemcall function I wrote which appends the design variables into a text file, calls ansys in batch mode to run the input file, ansys completes the analysis and writes the max stresses to more text files, then matlab reads the associated stress from the output files. In essence, you put the design variables in and get stresses out. The objective function takes the max stress and returns it to the optimizer.
I was having success when performing the optimization with only 1 variable using fminbnd. This has helped me narrow down the problem to matlab. I have also tried modifying fminimax and the same phenomenon occurs. When I bumped up the model complexity to more than one variable, I am forced to select a more appropriate optimizer. I have had success with fmincon in the past and am rather stumped as to why this is occurring. Any help would be appreciated. Thanks!