Help! naming matrices in matlab

  • MATLAB
  • Thread starter TimFys
  • Start date
  • #1
3
0

Main Question or Discussion Point

I have created a program in MatLab doing LU factorization and need to implement a routine, so that MatLab automatically runs the program on all of my matrices.

I have 6 matrices A1, A2, A3, A4, A5 and A6. But for the time being I can only run the program for one matrix, write the result down and then change the input matrix.

Is there a smart way of making a loop so that MatLab automatically changes the input matrix?

The notation A(i) does not work, since it refers to the elements in the matrix.
 

Answers and Replies

  • #2
Dr Transport
Science Advisor
Gold Member
2,393
524
look at sprintf() to write the variables then allocate A1 = zeros(x,x);

Matlab is faster if you do not use loops, but write out the code as a list

A1 = .....
A2 = .....

etc.......
 
  • #3
marcusl
Science Advisor
Gold Member
2,725
386
You can define a three-dimensional array A(l,m,n) so that one of your indices (I forget which one it is) points to the different matrices in a loop.
 
  • #4
Pythagorean
Gold Member
4,193
258
you might want to check out 'struct' (in conjunction with 'sprintf').
 

Related Threads on Help! naming matrices in matlab

  • Last Post
Replies
4
Views
3K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
5
Views
4K
Replies
1
Views
4K
  • Last Post
Replies
2
Views
2K
Replies
28
Views
54K
Replies
1
Views
3K
Replies
1
Views
25K
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
2
Views
2K
Top