Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using Matlab functions inside Fortran code: need help

Not open for further replies.


Junior Member level 3
Dec 12, 2005
Reaction score
Trophy points
Activity points
matlab fortran code

My work is on numerical techniques which require to solve sparse matrices etc. All my work is in fortran and I have almost no skill in Matlab.But I have just realized that Matlab can do some computations quite easily with its built-in functions and I want to take advantage of this. I have no time to learn Matlab deeply or work on matlab-fortran communication (very much off-focus issues and have deadline soon)

Some details:
I need to solve Ax=b system where A is very large and sparse matrix (20000x20000 or more). At every time step (iteration) I need to solve this system, get 'x' and reuse it for further computation in that step. [A] is fixed and formed before the iteration begins - but vector 'b' changes at every iteration. So in the iteration -- i) vector 'b' is formed, ii) solve Ax=b to find 'x' iii) use many other (explicit algebraic) equations to calculate some other values / fields (magnetic fields) iv) save field values for that step and move to the next step. Then these steps are repeated once and again. I am doing steps i), iii), iv) in fortran and want to do step ii) in matlab. Actually I have the whole code written in fortran but want to do some analysis by just doing the step ii) in Matlab. Can you please advise me if that is possible and if, how can I do that?

I have tried Matlab to solve Ax=b just for a single iteration. That means, I could read matrix [A], an instance of vector 'b' in matlab (after saving them in files from fortran). Then I solved them in Matlab command window using 'bicgstab' command (also used 'luinc' preconditioner etc, did some matrix blocking etc). But I need to repeatedly do this for the whole system and also calculate 'b' vector in fortran using the obtained solution. Can you please advise me on this. Thank you so much.

Not open for further replies.

Part and Inventory Search

Welcome to