How can I plot maximum values using a for loop in MATLAB?

In summary, the conversation discusses using a for loop to replace a number with a variable defined as a range of numbers, and then plotting the maximum of another function that uses the new variable. The output of the conversation is a new program that includes a for loop and plots the corresponding t values for each n value. The conversation also mentions an issue with one of the r values being zero and suggests using the plot function to graph the maximum t at each x.
  • #1
physicsCU
202
1
I wish to use a for loop i already made and replace a number with a variable defined as a range of numbers, then plot the max of another function that used the function with the new variable.

How would I do this?

example:

x = [0:.5:1]
r = 5*x
t = 3/r

new program:

x = same
n = [0:.25:.5]
r = n*x
t = 3/r

for each value of n, i want to plot the cooresponding t, and plot n vs t
 
Last edited:
Physics news on Phys.org
  • #2
I do not understand what it is you want to do. However your new program does not work. Try
x = [0:.5:1]
n = [0:.25:.5]
r = n.*x
t = 3./r

One of your r's will of course be zero, so you have a small problem with one t. if you want to plot it
plot(t,n)
 
  • #3
yes, i know about mtimes

it was simply an example. i guess i want to graph the max t at each x.
 

1. What are sensitivity plots in MATLAB?

Sensitivity plots in MATLAB are graphical representations of the sensitivity of a system's output to changes in its inputs. They are used to analyze the behavior of a system and identify the most influential parameters or inputs.

2. How do I create a sensitivity plot in MATLAB?

To create a sensitivity plot in MATLAB, you can use the "sensitivity" function. This function takes in the system model and the input and output variables, and then plots the sensitivities for each input variable.

3. Can sensitivity plots help with system optimization?

Yes, sensitivity plots can be a valuable tool in system optimization. By identifying the most influential parameters, they can help guide the optimization process and improve the system's overall performance.

4. Are there any limitations to using sensitivity plots in MATLAB?

While sensitivity plots can provide valuable insights, they are limited to linear systems and may not accurately represent the behavior of nonlinear systems. Additionally, they may not capture the effects of parameter interactions.

5. How can I interpret the results of a sensitivity plot in MATLAB?

The results of a sensitivity plot can be interpreted by looking at the magnitude and direction of the sensitivity values. A higher sensitivity value indicates that a particular input has a greater impact on the output, and a negative sensitivity value indicates an inverse relationship. By analyzing these results, you can identify the most critical inputs and make informed decisions about system design or optimization.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
985
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
246
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
752
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
928
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Back
Top