MATLAB- for loop saving results of 3 variables

  • Context: MATLAB 
  • Thread starter Thread starter Economist08
  • Start date Start date
  • Tags Tags
    Loop Matlab Variables
Click For Summary

Discussion Overview

The discussion revolves around using MATLAB to implement a for loop for iterating through a parameter that affects three variables in a set of non-linear equations. Participants seek assistance in saving the results of these iterations in a specific matrix format.

Discussion Character

  • Homework-related, Technical explanation

Main Points Raised

  • One participant describes their approach using MATLAB's fsolve function to solve three non-linear equations and expresses a desire to understand how changes in a parameter affect the three variables.
  • The same participant clarifies a previous statement regarding the dimensions of the matrix they wish to create, correcting the number of variables from a variable 'n' to a fixed number of three.
  • Another participant expresses a similar problem and requests a solution, indicating they are looking for insights or resolutions from past discussions.
  • A participant questions the clarity of the original inquiry and invites further clarification if needed.

Areas of Agreement / Disagreement

There is no consensus on a solution to the problem presented, and multiple participants express uncertainty or seek clarification on the original question.

Contextual Notes

Participants have not provided specific details on the equations or the nature of the non-linearities involved, nor have they resolved how to implement the matrix-saving aspect of their MATLAB code.

Who May Find This Useful

Individuals working with MATLAB for solving non-linear equations, particularly those interested in iterative methods and result storage in matrix formats.

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 ·
Replies
4
Views
2K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K