Matlab for loops involving matrix

  • MATLAB
  • Thread starter aplittle31
  • Start date
  • #1

Main Question or Discussion Point

Given the following system of equations
3x1 + ax2 = 1
ax1 + 4x2 = 0

where -pi ≤ a ≤ pi. We would like to find out the range of values of x1 and x2 that are observed as a is varied. Do this as follows:

1. Create a for loop that uses the variable a as the indexing value, varied from over the
specified range in increments of 0.2.
2. For each value of a, solve the above system by using the RREF function.
3. Also for each value of a, plot the values of x1 and x2 against the corresponding value of a
for each loop iteration (i.e. the coordinate pairs (a,x1) and (a,x2)). Include a legend in
your final plot! See MATLAB help for more details.
4. From the plot, determine the range of values for x1 and x2. You may use the data cursor
tool to pick off values from the plot.

I understand and have completed step 1. However I don't know how to assign each new a to a variable that can be plugged into the matrix for step 2. Right now my for loop looks like:

i=0.2;
for a=-1*pi:i:pi,
a
end
 

Answers and Replies

Related Threads on Matlab for loops involving matrix

  • Last Post
Replies
10
Views
3K
Replies
1
Views
17K
Replies
3
Views
4K
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
5
Views
3K
  • Last Post
Replies
1
Views
603
  • Last Post
Replies
10
Views
16K
Replies
1
Views
3K
Top