CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   can i use cfd using matlab (

ashraf80 September 27, 2012 08:30

can i use cfd using matlab
Dear all

can i use CFD Using MATLAB

if answer is yes ? if u have examples ,books ,thesis

i need to use CFD Using MATLAB for buildings (high rise building)
help me please

juanelo14 September 27, 2012 10:49

Yes you can. I don't know how much experience do you have in Matlab, but you can use fortran codes or C++ codes as a guide, and adapt it to MAtlab.

juanelo14 September 27, 2012 11:05

if you are new with this maybe this book can help you: "Applied Numerical Methods Using MATLAB" Won Y. Yang, Wenwu Cao,Tae-Sang Chung and John Morris.

francesco_capuano September 27, 2012 11:41

What do you think about the performances of Matlab with respect to Fortran or C/C++, for what concerns CFD-related codes? Does it work well in parallel?

I was wondering if a well-written Matlab code can be as fast as (or even faster than) consolidated languages such as Fortran or C.

wyldckat September 27, 2012 12:57

Greetings to all!


I was wondering if a well-written Matlab code can be as fast as (or even faster than) consolidated languages such as Fortran or C.
Short answer: NEVER! Never will MATLAB be faster than any properly code and compiled FORTRAN/C code, in terms of CPU performance and energy efficiency. Unless (a lot of) cheating is involved...

Long and rant'ish answer: I just got give my two (or ten) cents here :D
I've got plenty of experience coding with MATLAB, FORTRAN, C/C++ and I've even made C mex-files to speed up performance in performance-critical code that was running in MATLAB.

Unless todays MATLAB has super-evolved (it's been 5 years since last time I did any high performance related coding in MATLAB), but the principle should remain the same today:
  • MATLAB was created with fast and intuitive development of working code.
    It has evolved considerably over the years and todays MATLAB should be seriously faster than the first versions of MATLAB... 2... maybe 4 times faster than 15 years ago? I don't know any numbers on this. :rolleyes:
    But it will get it's ***** kicked any day by a very well written code in FORTRAN, C or even C++, when it comes to CPU performance. Assuming of course, you've compiled the code properly and have a working binary executable ;)
  • The reason is simple: FORTRAN and C have been created with performance in mind, and ease of use as a second choice... or in other words: FORTRAN and C are higher-level languages than Assembly or even pure machine code.
  • Because if you truly want performance, you've gotta go with Assembly or even pure bare metal machine code :D
    It'll take you a lot longer to code... and all sanity will escape you... but it'll be faster than anything you've ever seen... on that processor you're using :rolleyes:...
Anyway, you'll find better/more answers out on the Internet about "MATLAB vs C" and/or "MATLAB vs FORTRAN" ;)

The end result is usually always the same:
  • In MATLAB you can code something in a couple of minutes and it will run for several hours.
  • Or you can code in FORTRAN/C in a couple of hours and it will run under a minute :D ... if not under a second :cool:
Last but not least: when it comes to CFD, it all depends on what you need the code to do!? Fast running or fast development?

And then there's always the power factor: if you have only a few of hours to develop the code from scratch, but have a super-computer near by, then by all means, use MATLAB :rolleyes: assuming it's already installed and tested on said super-computer...
Of course this also assumes you've got a lot of experience in coding said specific CFD code you're planning on using... because CFD is a mathematical world in it's own right... ;)

Have fun!

francesco_capuano September 28, 2012 04:13

Thank you Bruno, I guess I couldn't hope for a better answer :D

All times are GMT -4. The time now is 19:25.