Which one is better, programming Numerical methods with Matlab or use programs like Ansys? For instance, if I want to analysis the temperature distribution or Fatigue life by finite element method, which way is better ?
ANSYS was specially created to developed finite element simulation, like those analysis that you mention. In ANSYS you will spend less time than MATLAB, because, you must write a lot of code at the last.
If you have programming skills, I suggest to try use OpenFOAM software (open source).
Using ANSYS might be a better option, although the decision depends on your coding skills. It is likely though that developing a matlab code takes longer than using ANSYS. Also, keep the validation of your code in mind although it can be easily done using the analytical solution of a simple problem.
Also, as Andres mentioned, in some cases the best option is to use a open source FE tool, which is highly dependent on your model and coding skills.
to be more precise, the finite element method was not devised to provide you "fatigue life". It is an approximate method only for estimating displacements, stress, strains, temperature, etc. You estimate fatigue life by post-processing FEM results in a subsequent step (for example, by Matlab or simply hand calculation). Although, to help users, this post-processing step is often accomplished by special tools directly within FE software, it does not strictly pertain to the "finite element" world
The word "Programming" in your question suggests you want to implement the finite element method yourself. That being the case MATLAB would be the best option of course. Temperature Distribution is a fairly easy problem and you can start simple on 2D problems (rectangles, circles, etc.) where you would be able to compare your finite element solution against other methods (for instance finite difference method) or even against established softwares like ANSYS or ABAQUS. As Denis mentioned above you don't evaluate fatigue damage (and life) by solving a finite element analysis but post-processing it, i.e., taking the results (stress and strain histories) and comparing against a fatigue curve. I would say that building a fatigue solver can be a fairly complex task on its own unless you're dealing with very simple problems like beams subjected to constant amplitude fully reversed bending loads. ANSYS WB offers a fatigue tool that you can try just to get the feeling of how the results get combined in order to provide fatigue lives and damage. If you need anything more advanced than that you may try later softwares like nCODE and fe-safe.
I agree with G.M. Teixeira and would like to give you my opinion too.
Many times similar Engineering problems are treated in the existing literature of the past and solved differently, because at that time, they hadn't computers, resources, eletronic technology to measure, test, etc. But this, doesn't say that their old answers are unadequate or completely outdated.
Therefore, if you want to research, you can always conjugate numerical methods [which doesn't need to be FEM, can be finite-diferences (RAM Silveira likes it and it is his area too)] or even other kinds of tools, which mean develop one.
Big softwares like ANSYS ABACUS are designed to use densy meshes and represent almost everything there, from pieces to componentes, medium to big problems, they have a multitude of modelling options.
*Then I ask you: did the problem (you want to analyze) require this canion to kill a fly? If the precision, the requirement of details and parts involved, the several answers (many points to analyze), many conditions to investigate, etc. this guide you to use the cannon. Even if after this you need to develop another tool to post-process these answers like seems to be the case of fatigue damage (or define the life of the components).
*Otherwise, if you have just a previous theory or background that allowed you to develop and trend new ways and analyze or investigate, using different resources, maybe you will feel more free and confortable to develop your own software. Matlab plataform can be very rich, some computer languages also can do many things for you. Today, almost all softwares are "running time", it means: you type the code and you see the answer and consequences immediately. Therefore, the programing task can be very quick and precise, because you know for sure, what the computer is doing. Sometimes, it can help you to find things that are often forgotten or even not mentioned in books or in the cannon manuals. In this case, maybe you can do the analysis and the post-process of this analysis combined.
I always feel worried about the black box that you don't know completely what is inside, only know the named task it is intended to do. Therefore, when some cannon produces unexpected answers, due to natural limits of software, modulation, parameters, hipothesis, etc. you can be lost in a jungle of numbers.
My option -as researcher- is to develop the software and if it is possible -to check this tool- against the cannion, to be sure that my gun kill the fly and leave the cannon for the hypopotamus. Try this, if all you want is to kill a fly...
described the problem (buying a car Vs. making it from scratch). This is going to explain the problem clearly. I think that nobody develop a code just for solving a problem that can be done with FEM software these days. Even in case of dealing with specific problems that can be tailored with commercial software, in my opinion using these software is more appropriate.
However, if you are trying to develop a new methodology or framework for extending FE methods (Capabilities) which are not "commercially available", then you can use mathematical software to make it and prove your concept. If the method you developed is attractive and useful enough, then commercial software will integrate it in their software and eventually will be readily available to everyone.
In my experience, connecting mathematical software like MATLAB with commercial FEM software provides more effective solution for solving problems. Just for giving you an example, I found FEM software are not proper options for performing stochastic FEA because of not having a proper random number generator function. This is where you can use the power of mathematical software to overcome FEM software shortcomings.
If you want to get familiar with FEM, you can probably combine both worlds: you can code in Matlab a simple 1D problem (Fourier's equation for example) that you solve using FE. By the way, you can also use excel to solve a differential equation...so the question is also if you want to know more about finite elements or the solution of a e.g. thermal problem. You should also consider Python, there are some existing FE frameworks you can adapt to your needs (and it's free)