Thread Closed

ARGH!!! Matlab trouble!!!

 
Share Thread Thread Tools
Oct10-04, 04:50 PM   #1
 

ARGH!!! Matlab trouble!!!


Ok, I'm having a big problem as described here: http://www.physicsforums.com/showthread.php?t=46950

Basically, I've never used matlab and was given an assignment on friday which requires that I use matlab. First off, could someone please help me with my projectile problem?

Next, how the heck does one write an m-file. I know how to open the editor and the simple stuff but actually using ODE45 is killing me. The help file is about as useful as a man file--good for pro's lousy for novices.

Any help would be greatly appreciated.
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Ants and carnivorous plants conspire for mutualistic feeding
>> Forecast for Titan: Wild weather could be ahead
>> Researchers stitch defects into the world's thinnest semiconductor
Oct14-04, 12:54 PM   #2
 
If you haven't already figured it out, there's nothing much to an .m file. Since i do not warez matlab, i'm using vim (a text editor) and octave. Basically what goes in a .m file is something like this
Code:
function returnValue = f(x)
     returnValue = 2*x^2 + 3*x+2
end

format long %for displaying more digits
result1 = f(4)
results = zeros(1,10); %creates a vector full of zeros, 10 big
results(1) =  f(6);
results(5)  = f(24);
Oct21-04, 05:13 AM   #3
 
Dont know about the projectile project but with the m - file i could help...
open a new m-file which can be found in File, then New... after which click on M-file...

Here u type in your code... when your done save it and give it a name (obviously... hehehe) now u can call your M-file from the command window in the main page...

however, if u want to make your own functions, wherein a created m-file will act like a regular function in matlab... all the functions in the matlab library have m-files as well... search for function in help to get details... to see what im talking about type this: type specgram

upon pressing enter, the entire code will come up... thats basically the same thing u need to do... the help for function is fairly easy to use...

hope i helped! Ü
Oct21-04, 05:16 AM   #4
 

ARGH!!! Matlab trouble!!!


Here's an example of an m-file i made

function [mag,f] = ffttrue(input,Fs)

framed = input;
lpf = lowpassf(framed,Fs) % fitered signal
X = fft(lpf); % FFT of signal
X(1) = 0;
N = length(X); % N = length of fft
mag = abs(X);
f = [0:N-1]*Fs/(N-1); % frequency vector

figure;plot(f,mag); % plot magnitude
xlabel('Frequency (Hertz)');
ylabel('X');
axis([0,680,0,max(mag)]); % display only frequencies < fs/2
Thread Closed
Thread Tools


Similar Threads for: ARGH!!! Matlab trouble!!!
Thread Forum Replies
General GRE---argh! Academic Guidance 12
Argh!!! General Math 0
Masterphysics again, ARGH! Introductory Physics Homework 1
GPE and KE...please help!!! argh General Physics 4
ARGH!! Bad night! General Discussion 5