Troubleshooting MATLAB Functions and Variables

Click For Summary
SUMMARY

The discussion centers on troubleshooting function and variable definitions in MATLAB scripts. A user is attempting to define multiple functions within a single script but encounters errors when trying to access constant values defined in the script from the function. The issue arises from the incorrect use of the function name "gammaf," which may refer to MATLAB's built-in "gamma" function. Properly structuring function definitions and ensuring correct variable scope are essential for successful execution.

PREREQUISITES
  • Understanding MATLAB function syntax and structure
  • Familiarity with variable scope in MATLAB
  • Knowledge of MATLAB built-in functions, specifically the gamma function
  • Basic MATLAB scripting skills
NEXT STEPS
  • Review MATLAB function definitions and variable scope
  • Learn about MATLAB error handling and debugging techniques
  • Explore MATLAB's built-in functions, focusing on the gamma function
  • Investigate best practices for organizing MATLAB scripts and functions
USEFUL FOR

MATLAB learners, engineers, and researchers who are developing scripts with multiple functions and need to troubleshoot variable access issues.

bocuk
Messages
1
Reaction score
0
i have a question.
i just try to learn MATLAB however i couldn't define the functions and variables inside the one script. i open new script file and give the function comment in it for example like this...


function [ y ] = betaf( x,Ee)
lambda=0.1;
y=100*gammaf(Ee)*lambda/(2*pi*x);

end


i also put constant values to script file but program doesn't recognize the function comment it gives error, i do this process in the function file...i define the function in function file and the values in script file... and then it doesn't read the constant values from the script file or script file doesn't see the function. i
i want to use about 10-15 function in the MATLAB and to put the values in one script ,then i but i coldnt. or may be any easy way to make it?

can anybody help me?
 
Physics news on Phys.org
bocuk said:
y=100*gammaf(Ee)*lambda/(2*pi*x);
What function is this gammaf? Matlab has a function gamma (without a "f"), maybe you meant that one?
 

Similar threads

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