Help me Solve MATLAB Projectile Problem & Write an m-file

  • Context: MATLAB 
  • Thread starter Thread starter faust9
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion centers on using MATLAB for a projectile motion assignment and writing an m-file. The user expresses frustration with the ODE45 function and seeks guidance on creating m-files. A basic example of an m-file is provided, demonstrating function creation and vector initialization. The user also mentions using Vim and Octave as alternatives to MATLAB.

PREREQUISITES
  • Basic understanding of MATLAB syntax and functions
  • Familiarity with ODE45 for solving ordinary differential equations
  • Knowledge of vector operations in MATLAB
  • Experience with text editors like Vim for coding
NEXT STEPS
  • Learn how to implement ODE45 in MATLAB for solving projectile motion problems
  • Explore MATLAB's built-in help functions for better understanding of m-files
  • Study vector manipulation techniques in MATLAB
  • Investigate Octave as an alternative to MATLAB for similar functionalities
USEFUL FOR

Students and beginners in programming, particularly those tackling MATLAB assignments, as well as educators looking for practical examples of function creation and vector operations in MATLAB.

faust9
Messages
690
Reaction score
2
ARGH! Matlab trouble!

Ok, I'm having a big problem as described here: https://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.
 
Physics news on Phys.org
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);
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K