Matlab help User defined function

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

The forum discussion centers on a user-defined function in MATLAB for calculating height based on time, initial velocity, and angle. The function, defined as Ht=V*t*sin(Theta)-4.9*t.^2, encounters an error indicating that the variable "V" is undefined. Users are prompted to clarify the command used to test the function, highlighting the importance of proper variable initialization in MATLAB.

PREREQUISITES
  • Understanding of MATLAB syntax and functions
  • Familiarity with variable initialization in MATLAB
  • Basic knowledge of physics equations related to projectile motion
  • Experience with MATLAB debugging techniques
NEXT STEPS
  • Review MATLAB documentation on user-defined functions
  • Learn about variable scope and initialization in MATLAB
  • Explore MATLAB's debugging tools to troubleshoot function errors
  • Study projectile motion equations to enhance understanding of the function's application
USEFUL FOR

Students, educators, and professionals working with MATLAB who need assistance in creating and debugging user-defined functions, particularly in the context of physics simulations.

qiyan31
Messages
3
Reaction score
0
I made a user-defined function for Height.
function Ht=Height(t,V,Theta);
Ht=V*t*sin(Theta)-4.9*t.^2;
end

V is initial velocity, and i kept on getting input "V" is undefined.
Can someone help me please!
 
Physics news on Phys.org
Works fine for me. What is the precise command that you're using to test the function?
 

Similar threads

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