MATLAB MATLAB- for loop saving results of 3 variables

AI Thread Summary
The discussion centers on using MATLAB for iterating through three non-linear equations to analyze how three variables respond to changes in a parameter ranging from 1 to 5. The user is employing the 'fsolve' function to find solutions, starting with an initial guess of [1; 1; 1], and is looking to store the results in a 3x5 matrix. There is a request for assistance in implementing this iteration method effectively. Additionally, another participant expresses a similar issue and inquires about any solutions that may have been found since the original post, indicating ongoing interest in resolving the problem.
Economist08
Messages
5
Reaction score
0
MATLAB- for loop and interation

Hi
I'm using an interation method to solve for 3 variables in 3 non-linear equations. I would like to find out, how the 3 variables change, when I change a parameter in the 3 equations. Let's assume the parameter runs from 1 to 5 (1:1:5).

The iteration looks like this:
x0 = [1; 1; 1]; % Make a starting guess at the solution
options=optimset('Display','iter'); % Option to display output
[x,fval] = fsolve('file_that defines_the_3_functions',x0,options) % Call optimizer, where x is vector of the 3 variables

Preferable I would like to save the results in a 3*5 matrix, where n is the number variables and 5 the number of different parameters.
Please help!

Thanks in advance.
 
Last edited:
Physics news on Phys.org
In the last sentence, I meant "where 3 is the number of variables...", not n.
 
Is this question not clear? Please let me know, when I need to clarify the question. :smile:
 
I have the same problem!
I know this was posted 3 years ago, so if you managed to solve the problem can you please share the solution?
Thank you!
 

Similar threads

Replies
4
Views
1K
Replies
18
Views
4K
Replies
5
Views
2K
Replies
8
Views
2K
Replies
5
Views
3K
Back
Top