| Thread Closed |
Fminsearch - hold a variable constant |
Share Thread |
| Mar1-08, 08:38 AM | #1 |
|
|
Fminsearch - hold a variable constant
Hello,
I want to pass a number of variables through fminsearch. Because of the structure of the program, some of those variables must be held constant while the others are minimized. Is there a way to do this with fminsearch, or is there another minimization program which allows this? Thanks, jimpx |
| Mar2-08, 11:51 PM | #2 |
|
|
If you can give me more details on what fminsearch is all about, I may be able to help you better. Best regards, Eus |
| Mar3-08, 10:38 AM | #3 |
|
|
Thanks for the reply Eus.
Unfortunately that won't work. I am designing a GUI for a program already written. The program calls on 7 functions, sending three variables to the first function, which returns six variables, two of which go to the second and three to the third etc. The GUI sends the three initial variables to the main program which minimizes the answer and returns a result. I want to send a filename to the main program which will send it to the 6th function to compare. However, if this function is to receive the filename, it will have to receive it at every stage of the fminsearch loop, so I will need to keep the filename from being varied. Thanks again, Jimpx |
| Mar3-08, 11:15 PM | #4 |
|
|
Fminsearch - hold a variable constantOr, by using the API of the program? So, if the program follows that principle, you should not need to worry about the filename being modified. If you are willing to give more details on the environment in which the program is run, the mechanism of communication between your GUI and the program, and the details of the fminsearch, we may help you better. Best regards, Eus |
| Mar14-08, 07:44 AM | #5 |
|
|
Thanks again for your help Eus,
I will try to explain the environment a bit better. The original program takes in three variables which are plasma parameters, and calculates the expected spectrum based on these variables. This calculation requires a total of seven different codes, which send and receive certain variables. One of these codes opens a file, which is an experimental spectrum, and compares the calculated with the experimental. A graph is plotted. To match the calculated spectrum with the experimental, fminsearch is run. It minimizes the difference between the two and returns three variables which closely match with the experimental spectrum. All of the above runs fine. However, to implement the GUI, more than just the three variables must be sent. I want to create other options in the GUI, most importantly the option of choosing a file to compare the spectrum with. However, to send a filename I will have to do it via fminsearch, since the code that compares the calculated and experimental is not the main program but one of the seven in the loop. Hence I need to be able to send the filename as part of a vector which will now hold 4 variables. Can I send a 4 variable vector through fminsearch but only vary 3 of the variables? I can send the files if you want a closer look. Thanks again, Jimpx |
| Mar14-08, 08:57 AM | #6 |
|
|
But, will the function that eventually opens the file know whether there is an extra variable in the vector that is passed into it? If it doesn't know anything about the extra variable, you cannot tell the function to open a different file than usual, can you? What I want to know is how that function that opens the file know what file it is supposed to open. Does the filename hard-coded in the function definition? If not, how could the function what file it should open? Yes, please send the files. Best regards, Eus |
| Mar14-08, 11:09 AM | #7 |
|
|
The code is written in Matlab. If you run RunsakkaGUI there should be two plots. The one on the left will work, as its only a single run of the program. The one on the right works, but only with the file that's written into the minimization code. I have included two sample files. Thanks,
jimpx |
| Mar14-08, 11:20 AM | #8 |
|
|
try sigma_1 = 1e3, N_2b = 1e19, N_e0=1e24
|
| Mar17-08, 11:10 AM | #9 |
|
|
I have never used MathLab before.
Therefore, I think I cannot help you further. I hope someone else in this forum can help you with that. Best regards, Eus |
| Mar18-08, 02:53 PM | #10 |
|
|
Thanks alot for your help anyway Eus, it's much appreciated.
|
| Thread Closed |
Similar discussions for: Fminsearch - hold a variable constant
|
||||
| Thread | Forum | Replies | ||
| Constant or Variable Coefficients? | Calculus & Beyond Homework | 2 | ||
| Variable constant? | Calculus & Beyond Homework | 3 | ||
| Variable Planck's Constant | Cosmology | 2 | ||
| The variable R as the Universal Gas Constant | Biology, Chemistry & Other Homework | 1 | ||
| constant or variable coefficient? | Differential Equations | 4 | ||