# How to create Data.mat file for Convex.jl to solve optimal power flow using Matpower?

**URL:** <https://discourse.julialang.org/t/how-to-create-data-mat-file-for-convex-jl-to-solve-optimal-power-flow-using-matpower/80924>\
**Category:** Optimization (Mathematical)\
**Tags:** convex\
**Created:** [May 12, 2022, 2:36am UTC](https://discourse.julialang.org/t/how-to-create-data-mat-file-for-convex-jl-to-solve-optimal-power-flow-using-matpower/80924 "2022-05-12T02:36:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![biswajit216](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/biswajit216/32/12645_2.png) [@biswajit216](https://discourse.julialang.org/u/biswajit216)\
**Post date:** [May 12, 2022, 2:36am UTC](https://discourse.julialang.org/t/how-to-create-data-mat-file-for-convex-jl-to-solve-optimal-power-flow-using-matpower/80924/1 "2022-05-12T02:36:49Z")

</div>

Hi,  
I’m a newbie learning Julia for optimal power flow formulation using convex optimization. I came across an example from Convex.jl documentation in here  
[https://jump.dev/Convex.jl/stable/examples/optimization\_with\_complex\_variables/power\_flow\_optimization/](https://jump.dev/Convex.jl/stable/examples/optimization_with_complex_variables/power_flow_optimization/)

In the example code the used “Data.mat” for the system parameters. I want to know how can I create the Data.mat file for any system provided in the Data folder of Matpower?  
Thank you.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 12, 2022, 2:47am UTC](https://discourse.julialang.org/t/how-to-create-data-mat-file-for-convex-jl-to-solve-optimal-power-flow-using-matpower/80924/2 "2022-05-12T02:47:29Z")

</div>

Checkout [Home · PowerModels](https://lanl-ansi.github.io/PowerModels.jl/stable/). It has lots of tools for working with this sort of thing. It also has a lot of model formulations pre-built, so you don’t have to write your own.
