MATLAB thread - Page 3
Forum Index > General Forum |
AoN.DimSum
United States2983 Posts
| ||
clazziquai
6685 Posts
"Perhaps the most famous equation in physics is: E=mc^2" which relates energy E to mass m. The speed of light in a vacuum = c. Which is 2.9979*10^8 m/s and it asks me to create a function called energy to find the energy corresponding to a given masss in kg. your result will be in joules since 1 kg m^2/s^2 = 1 joule | ||
brjdrb
United States577 Posts
| ||
GrayArea
United States872 Posts
| ||
Raithed
China7077 Posts
On September 27 2008 17:39 clazziquai wrote: LOL damn... so far it's not that bad. I fell asleep in one of the lectures that had to do with the project due so I need to review it. So I have no idea haha I'm on Matrices and vectors btw... so this was your reason in making a thread in general as opposed to blog. you want someone to teach you how. | ||
prOxi.swAMi
Australia3091 Posts
| ||
Meta
United States6225 Posts
%%%%%%%%%%%% function energy = holycrap(mass) c = 2.9979*10^8 energy = mass*c^2 %%%%%%%%%%%% then you just type holycrap(mass) and it calculates it based on what mass you put in | ||
KlaCkoN
Sweden1648 Posts
implicit none double precision Energy, m, c c=2.9979d8 Energy=m*c^2 return end Fortran syntacs but if I remember correctly MATLAB is similar when it comes to stuff like this. Just make a text file with this and I think it should work, at least it's somewhere to start. Maybe the variable declaration is unnecessary? What this means is that when you in you program write Energy(m) this function will be called with whatever value the variable m currently has. The function will then be executed and calculate m*c^2 and give the resulting value to the variable Energy, meaning Energy(m) takes on the value of m*c^2. Looking at other posted functions it seems like matlab syntax was indeed a bit different, use the others :p THe reasoning behind them is the same though | ||
KOFgokuon
United States14883 Posts
| ||
clazziquai
6685 Posts
On October 27 2008 08:19 Raithed wrote: so this was your reason in making a thread in general as opposed to blog. you want someone to teach you how. you, my friend, are wrong. i may have fallen asleep, but did everything by MYSELF on the project which i got a 100 for. sorry ntnt | ||
jgad
Canada899 Posts
On October 27 2008 08:04 clazziquai wrote: Guys I have a question with functions. I have absolutely no idea how to do this one. "Perhaps the most famous equation in physics is: E=mc^2" which relates energy E to mass m. The speed of light in a vacuum = c. Which is 2.9979*10^8 m/s and it asks me to create a function called energy to find the energy corresponding to a given masss in kg. your result will be in joules since 1 kg m^2/s^2 = 1 joule function definitions in matlab are straightforward. For this you'd do something like + Show Spoiler + function [eofm] = energy(m) %define a function, "eofm" is an output, "energy" is the name of the function, and "m" is a variable taken into the function to do stuff with inside c = 299792458; % define 'c', speed of light eofm = m*c^; % do the calculation and set the output 'eofm' equal to it. lots of functions, it seems ^^ | ||
KlaCkoN
Sweden1648 Posts
On October 27 2008 08:21 prOxi.swAMi wrote: Why you'd introduce students to computing using matlab I have no idea. Pascal is the best learner's language ever. Never used pascal, but matlab is reaaaly user friendly in my opinion. You can do quite fun stuff quite quickly. Not exactly quick code though, so I don't understand what kind of guys that are using it proffesionally? | ||
jgad
Canada899 Posts
On October 27 2008 08:28 KlaCkoN wrote: Never used pascal, but matlab is reaaaly user friendly in my opinion. You can do quite fun stuff quite quickly. Not exactly quick code though, so I don't understand what kind of guys that are using it proffesionally? I work in physics research and it's the sort of thing a lot of people have around. The guys who are doing number intensive stuff like quantum chemical computations, they tend to write their own code in C++ for obvious performance reasons. Lots of other people, though, who simply have to do big analysis on large data sets, use it quite a bit. For things up to a few million data points, give or take an order of magnitude depending on what you're working on, it's quick and simple and handy. I've used it to do simple backprojection calculations on CAT scan data, to analyse materials and prototype testing data, to collate and mass-crunch big data sets. The applications are endless. | ||
KlaCkoN
Sweden1648 Posts
On October 27 2008 08:35 jgad wrote: I work in physics research and it's the sort of thing a lot of people have around. The guys who are doing number intensive stuff like quantum chemical computations, they tend to write their own code in C++ for obvious performance reasons. Lots of other people, though, who simply have to do big analysis on large data sets, use it quite a bit. For things up to a few million data points, give or take an order of magnitude depending on what you're working on, it's quick and simple and handy. I've used it to do simple backprojection calculations on CAT scan data, to analyse materials and prototype testing data, to collate and mass-crunch big data sets. The applications are endless. Alright thanks My experience is obviously quite limited. (To a 3 month q.chem project :p) (So a few million data points seem like an awfully small number ) Never used C++ either but it is on par with fortran and python and such then? when it comes to speed. | ||
dongfeng
731 Posts
| ||
thunk
United States6233 Posts
It's like trying to play Starcraft without knowing any of the builds. | ||
DrainX
Sweden3187 Posts
I did a project in Matlab two years ago where we modeled how pollution would spread in the air using fluid motion partial differential equations. | ||
imDerek
United States1944 Posts
| ||
clazziquai
6685 Posts
On October 27 2008 09:06 imDerek wrote: using it on my EE labs Electrical Engineering? | ||
fight_or_flight
United States3988 Posts
Where I work, we are going to be using Simulink, which is an addon to matlab, to start work on software-defined radios. A software defined-radio is, in its purest form, a D/A converter connected to an antenna. Then you can have a single device that acts as a cellphone, wifi, GPS, or any other type of radio you want. Simulink models dynamic systems, such as communications systems or control systems. It can take models, or chunks matlab embedded or C code, and you can create an entire radio out of it. It can then compile that entire model onto an FPGA or DSP chip. Matlab is THE software package used for DSP applications. | ||
| ||