Finding the x that makes y minimum in MATLAB.

  • Thread starter Thread starter btbam91
  • Start date Start date
  • Tags Tags
    Matlab Minimum
Click For Summary

Discussion Overview

The discussion revolves around finding the value of 'x' that minimizes a function 'y' in MATLAB, as well as plotting multiple data series on a single xy plot. Participants explore methods for both optimization and data visualization within the MATLAB environment.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant inquires about determining the 'x' that minimizes 'y', suggesting a calculus approach and the use of MATLAB functions.
  • Another participant expresses a desire for MATLAB to handle the minimization automatically, indicating a preference for built-in functions.
  • Multiple participants discuss plotting different data series in MATLAB, with suggestions to use functions like plot(), hold on, and vector operations.
  • Specific MATLAB code snippets are provided by participants for both finding minima and plotting, including the use of diff() and polyder() for derivative calculations.
  • A participant shares a more complex example involving physical constants and data series, seeking advice on how to automate the plotting process without rewriting code for each dataset.
  • Suggestions include using loops to streamline the plotting process and maintain clarity in the code structure.

Areas of Agreement / Disagreement

Participants generally agree on the methods for plotting multiple data series and finding minima, but there is no consensus on a single best approach for either task, as various methods and code snippets are proposed.

Contextual Notes

Some participants' suggestions depend on the specific structure of the data and the definitions of variables used in the MATLAB code, which may not be universally applicable.

Who May Find This Useful

This discussion may be useful for MATLAB users interested in optimization techniques and data visualization, particularly in the context of scientific computing and data analysis.

btbam91
Messages
91
Reaction score
0
Hello.

As stated in the title, I have a function y that is in terms of x. How do I go about determing the 'x' that makes 'y' a minimum?

Thanks!
 
Physics news on Phys.org
Think calculus: how can you find a minimum of a function? Then, it's just a matter of telling MATLAB to do this.
 
Duhhh, I guess I was just being lazy and expecting a MATLAB function to handle it for me.

Thanks!
 
Hi
Is there anyone help me with Matlab
I have got different data series of x and y, and want to plot them in a single xy plot using a single written program, can you advice?
Emmanuel
 
@btbam91:
If you have data in vector form, you can use diff() or polyder(). You might actually be able to do:
Code:
[yMin I] = min(y)
% corresponding x is:
x(I)
Symbolically, you can use diff() and then solve().

@manyoolo:
"hold on" will allow multiple data to be plotted on the same plot.
 
manyoolo said:
Hi
Is there anyone help me with Matlab
I have got different data series of x and y, and want to plot them in a single xy plot using a single written program, can you advice?
Emmanuel

This:
plot(x1,y1,x2,y2,x3,y3);

or if all x and y's are same length:
plot( [ x1 x2 x3 ], [ y1 y2 y3]);

or as already mentioned:
plot(x1, y1);
hold on;
plot(x2, y2);
plot(x3, y3);
hold off;
 
jhae2.718 said:
@btbam91:
If you have data in vector form, you can use diff() or polyder(). You might actually be able to do:
Code:
[yMin I] = min(y)
% corresponding x is:
x(I)
Symbolically, you can use diff() and then solve().

@manyoolo:
"hold on" will allow multiple data to be plotted on the same plot.[/QUO

Dear
This is what I have
h=4.14*10^-15;%eV.s
c=3*10^8%m/s^2
d=124.38*10^-9%m;
lambda= (W50)*10^-9%m
T=T50./100;
y=-(log(T));
alpha=y*(1/d);
nu=(1./lambda).*c;
A=nu.*(alpha).*(h);
D=sqrt(A)
B=nu.*(h);
%plot (B,D, 'om')

hold on
h=4.14*10^-15;%eV.s
c=3*10^8%m/s^2
d=93.06*10^-9%m;
lambda= (W47)*10^-9%m
T=T47./100;
y=-(log(T));
alpha=y*(1/d);
nu=(1./lambda).*c;
A=nu.*(alpha).*(h);
D=sqrt(A)
B=nu.*(h);
%plot (B,D, 'og')

this programs give me good plots in single xy plane
AND my goal is to write only one program in which the program will be able to go and pick the data series ie (W50,T50), (W47, T47)...and plot the graphs without necessarily repeat writing the program for each data series
Hope you got my point
 
manyoolo said:
this programs give me good plots in single xy plane
AND my goal is to write only one program in which the program will be able to go and pick the data series ie (W50,T50), (W47, T47)...and plot the graphs without necessarily repeat writing the program for each data series
Hope you got my point

Use a for loop and place hold off at the end.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K