text: # How to graph separate functions from a loop and find their max's?
  
  1 view (last 30 days)
  Danielle Guariglia on 20 Apr 2021
  Answered: Aghamarsh Varanasi on 23 Apr 2021
  so i have a function that i need to change one variable a few different times.
  I used a for loop and got a few different function outputs, which is what i want.
  But i need to plot each one of those functions and find the absolute max on each one as well. I know it will be loops within loops i am just not sure how to call up each individual funtion to graph and then evaluate.
  syms t
  ymax = 0;
  dt = .5;
  for w = 4:dt:7
  x = (4/(-w^2+36))*cos(6*t) + (2/3)*sin(6*t) - (4/(-w^2+36))*cos(w*t)
  end
  these are the functions i get in the command window
  x =
  cos(6*t)/5 - cos(4*t)/5 + (2*sin(6*t))/3
  x =
  (16*cos(6*t))/63 - (16*cos((9*t)/2))/63 + (2*sin(6*t))/3
  x =
  (4*cos(6*t))/11 - (4*cos(5*t))/11 + (2*sin(6*t))/3
  x =
  (16*cos(6*t))/23 - (16*cos((11*t)/2))/23 + (2*sin(6*t))/3
  x =
  NaN
  x =
  (16*cos((13*t)/2))/25 - (16*cos(6*t))/25 + (2*sin(6*t))/3
  x =
  (4*cos(7*t))/13 - (4*cos(6*t))/13 + (2*sin(6*t))/3
  >>
  
  Aghamarsh Varanasi on 23 Apr 2021
  Hi,
  You can use the 'fplot' function to plot a function or expression. To calculate the local maxima or local minima of a function, you can refer to this documentation page.
  Hope this helps
explanation: The text extract is a forum post from a user asking for help with MATLAB code. The user is trying to graph separate functions generated from a loop and find their maximum values. The post includes the user's code and the functions generated. An answer is provided by another user, suggesting the use of the `fplot` function for plotting and a link to documentation for finding local maxima or minima.
distilabel_metadata.content: Evaluate the user given text extract and determine if it contains a math question and optionally and answer to this question.
  
  Output rules:
  
  1. Briefly describe the document and mention if it contains a question or a question and answer.
  2. Finalize the output with: Label: no-question,question,question-and-answer,multiple-question,multiple-question-and-answer
distilabel_metadata.role: system
distilabel_metadata.content: # How to graph separate functions from a loop and find their max's?
  
  1 view (last 30 days)
  Danielle Guariglia on 20 Apr 2021
  Answered: Aghamarsh Varanasi on 23 Apr 2021
  so i have a function that i need to change one variable a few different times.
  I used a for loop and got a few different function outputs, which is what i want.
  But i need to plot each one of those functions and find the absolute max on each one as well. I know it will be loops within loops i am just not sure how to call up each individual funtion to graph and then evaluate.
  syms t
  ymax = 0;
  dt = .5;
  for w = 4:dt:7
  x = (4/(-w^2+36))*cos(6*t) + (2/3)*sin(6*t) - (4/(-w^2+36))*cos(w*t)
  end
  these are the functions i get in the command window
  x =
  cos(6*t)/5 - cos(4*t)/5 + (2*sin(6*t))/3
  x =
  (16*cos(6*t))/63 - (16*cos((9*t)/2))/63 + (2*sin(6*t))/3
  x =
  (4*cos(6*t))/11 - (4*cos(5*t))/11 + (2*sin(6*t))/3
  x =
  (16*cos(6*t))/23 - (16*cos((11*t)/2))/23 + (2*sin(6*t))/3
  x =
  NaN
  x =
  (16*cos((13*t)/2))/25 - (16*cos(6*t))/25 + (2*sin(6*t))/3
  x =
  (4*cos(7*t))/13 - (4*cos(6*t))/13 + (2*sin(6*t))/3
  >>
  
  Aghamarsh Varanasi on 23 Apr 2021
  Hi,
  You can use the 'fplot' function to plot a function or expression. To calculate the local maxima or local minima of a function, you can refer to this documentation page.
  Hope this helps
distilabel_metadata.role: user
distilabel_metadata.raw_output_q_a_detector_0: The text extract is a forum post from a user asking for help with MATLAB code. The user is trying to graph separate functions generated from a loop and find their maximum values. The post includes the user's code and the functions generated. An answer is provided by another user, suggesting the use of the `fplot` function for plotting and a link to documentation for finding local maxima or minima.
  
  Label: question-and-answer