How to Find the Maximum of a Function in MATLAB?

  • Context: MATLAB 
  • Thread starter Thread starter Black-Mind
  • Start date Start date
  • Tags Tags
    Maximum
Click For Summary
SUMMARY

To find the maximum of a function in MATLAB, start by defining the symbolic variable using syms T. Next, define your function, for example, f=((((cos(T))^2+(sin(T)*cos(T)))^2)+3*(((sin(T))^2+(sin(T)*cos(T)))^2))^(0.5). Differentiate the function with diff(f,T) to find critical points. However, due to the representation of continuous functions by discrete data in MATLAB, finding exact maxima may require additional techniques such as using the findpeaks function.

PREREQUISITES
  • Understanding of symbolic variables in MATLAB
  • Familiarity with differentiation in MATLAB
  • Knowledge of continuous versus discrete functions
  • Basic understanding of the findpeaks function in MATLAB
NEXT STEPS
  • Learn how to use the findpeaks function in MATLAB for identifying local maxima
  • Explore numerical methods for finding maxima, such as fminunc or fmincon
  • Study the implications of using discrete data to represent continuous functions in MATLAB
  • Investigate the use of optimization toolboxes in MATLAB for more complex functions
USEFUL FOR

Students and professionals new to MATLAB, mathematicians seeking to optimize functions, and engineers looking to analyze data for maximum values.

Black-Mind
Messages
7
Reaction score
0
I'm new on MATLAB and I need to find the value that make the derivative of a function = 0 in order to find the maximum of my function

I started by defining the variable T

>> syms T

Then I but my function

>> f=((((cos(T))^2+(sin(T)*cos(T)))^2)+3*(((sin(T))^2+(sin(T)*cos(T)))^2))^(0.5)

Then I diffrentiate the function with respect to T

>> diff(f,T)

But know i want to find the value that make my function equal to zero but I can't figure it out espically that I'm new on matlab

If anybody can help me I'll be thankfull
 
Physics news on Phys.org
help findpeaks

http://www.mathworks.com/help/toolbox/signal/ref/findpeaks.htmlWhen you use MATLAB for this you are representing a continuous function by a discrete one. For this reason, the exact point of the extreema may not have been included in your data set. So - differentiating the function and looking for the points that are equal to zero will usually be unhelpful.
 
Thanks that was very helpfull
 
Last edited by a moderator:

Similar threads

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